@tldraw/editor 3.16.0-next.f9f54ec051f3 → 4.0.0
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 +197 -114
- package/dist-cjs/index.js +5 -5
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +9 -9
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/MenuClickCapture.js +0 -5
- package/dist-cjs/lib/components/MenuClickCapture.js.map +2 -2
- package/dist-cjs/lib/components/Shape.js +7 -10
- package/dist-cjs/lib/components/Shape.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js +14 -23
- package/dist-cjs/lib/components/default-components/DefaultCanvas.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +1 -1
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultScribble.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultScribble.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js +9 -1
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
- package/dist-cjs/lib/config/TLUserPreferences.js +21 -4
- package/dist-cjs/lib/config/TLUserPreferences.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +121 -138
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js +4 -0
- package/dist-cjs/lib/editor/derivations/notVisibleShapes.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js +4 -2
- package/dist-cjs/lib/editor/managers/FocusManager/FocusManager.js.map +2 -2
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js +14 -4
- package/dist-cjs/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +23 -0
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/types/misc-types.js.map +1 -1
- package/dist-cjs/lib/exports/getSvgJsx.js +35 -16
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +47 -38
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useDocumentEvents.js +5 -5
- package/dist-cjs/lib/hooks/useDocumentEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js +1 -2
- package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useGestureEvents.js +1 -1
- package/dist-cjs/lib/hooks/useGestureEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useHandleEvents.js +6 -6
- package/dist-cjs/lib/hooks/useHandleEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js +4 -1
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js +4 -1
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useSelectionEvents.js +8 -8
- package/dist-cjs/lib/hooks/useSelectionEvents.js.map +2 -2
- package/dist-cjs/lib/{utils/nearestMultiple.js → hooks/useStateAttribute.js} +15 -14
- package/dist-cjs/lib/hooks/useStateAttribute.js.map +7 -0
- package/dist-cjs/lib/license/LicenseManager.js +143 -53
- package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
- package/dist-cjs/lib/license/LicenseProvider.js +39 -1
- package/dist-cjs/lib/license/LicenseProvider.js.map +2 -2
- package/dist-cjs/lib/license/Watermark.js +144 -75
- package/dist-cjs/lib/license/Watermark.js.map +3 -3
- package/dist-cjs/lib/license/useLicenseManagerState.js.map +2 -2
- package/dist-cjs/lib/options.js +7 -0
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/primitives/Box.js +3 -0
- package/dist-cjs/lib/primitives/Box.js.map +2 -2
- package/dist-cjs/lib/primitives/Vec.js +0 -4
- package/dist-cjs/lib/primitives/Vec.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js +50 -20
- package/dist-cjs/lib/primitives/geometry/Geometry2d.js.map +2 -2
- package/dist-cjs/lib/primitives/geometry/Group2d.js +8 -1
- package/dist-cjs/lib/primitives/geometry/Group2d.js.map +2 -2
- package/dist-cjs/lib/utils/EditorAtom.js +45 -0
- package/dist-cjs/lib/utils/EditorAtom.js.map +7 -0
- package/dist-cjs/lib/utils/dom.js.map +2 -2
- package/dist-cjs/lib/utils/getPointerInfo.js +2 -3
- package/dist-cjs/lib/utils/getPointerInfo.js.map +2 -2
- package/dist-cjs/lib/utils/reparenting.js +7 -36
- package/dist-cjs/lib/utils/reparenting.js.map +3 -3
- package/dist-cjs/version.js +4 -4
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +197 -114
- package/dist-esm/index.mjs +5 -5
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +9 -9
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/MenuClickCapture.mjs +0 -5
- package/dist-esm/lib/components/MenuClickCapture.mjs.map +2 -2
- package/dist-esm/lib/components/Shape.mjs +7 -10
- package/dist-esm/lib/components/Shape.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs +14 -23
- package/dist-esm/lib/components/default-components/DefaultCanvas.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +1 -1
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs +9 -1
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +2 -2
- package/dist-esm/lib/config/TLUserPreferences.mjs +21 -4
- package/dist-esm/lib/config/TLUserPreferences.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +121 -138
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs +4 -0
- package/dist-esm/lib/editor/derivations/notVisibleShapes.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs +4 -2
- package/dist-esm/lib/editor/managers/FocusManager/FocusManager.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs +14 -4
- package/dist-esm/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +23 -0
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +36 -16
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +49 -45
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useDocumentEvents.mjs +6 -6
- package/dist-esm/lib/hooks/useDocumentEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs +1 -2
- package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useGestureEvents.mjs +2 -2
- package/dist-esm/lib/hooks/useGestureEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useHandleEvents.mjs +6 -6
- package/dist-esm/lib/hooks/useHandleEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs +4 -1
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs +4 -1
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useSelectionEvents.mjs +9 -14
- package/dist-esm/lib/hooks/useSelectionEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useStateAttribute.mjs +15 -0
- package/dist-esm/lib/hooks/useStateAttribute.mjs.map +7 -0
- package/dist-esm/lib/license/LicenseManager.mjs +144 -54
- package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
- package/dist-esm/lib/license/LicenseProvider.mjs +39 -2
- package/dist-esm/lib/license/LicenseProvider.mjs.map +2 -2
- package/dist-esm/lib/license/Watermark.mjs +145 -76
- package/dist-esm/lib/license/Watermark.mjs.map +3 -3
- package/dist-esm/lib/license/useLicenseManagerState.mjs.map +2 -2
- package/dist-esm/lib/options.mjs +7 -0
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/primitives/Box.mjs +4 -1
- package/dist-esm/lib/primitives/Box.mjs.map +2 -2
- package/dist-esm/lib/primitives/Vec.mjs +0 -4
- package/dist-esm/lib/primitives/Vec.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs +53 -21
- package/dist-esm/lib/primitives/geometry/Geometry2d.mjs.map +2 -2
- package/dist-esm/lib/primitives/geometry/Group2d.mjs +8 -1
- package/dist-esm/lib/primitives/geometry/Group2d.mjs.map +2 -2
- package/dist-esm/lib/utils/EditorAtom.mjs +25 -0
- package/dist-esm/lib/utils/EditorAtom.mjs.map +7 -0
- package/dist-esm/lib/utils/dom.mjs.map +2 -2
- package/dist-esm/lib/utils/getPointerInfo.mjs +2 -3
- package/dist-esm/lib/utils/getPointerInfo.mjs.map +2 -2
- package/dist-esm/lib/utils/reparenting.mjs +8 -41
- package/dist-esm/lib/utils/reparenting.mjs.map +2 -2
- package/dist-esm/version.mjs +4 -4
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +308 -290
- package/package.json +14 -37
- package/src/index.ts +4 -9
- package/src/lib/TldrawEditor.tsx +14 -21
- package/src/lib/components/MenuClickCapture.tsx +0 -8
- package/src/lib/components/Shape.tsx +6 -12
- package/src/lib/components/default-components/DefaultCanvas.tsx +11 -22
- package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +1 -1
- package/src/lib/components/default-components/DefaultErrorFallback.tsx +1 -1
- package/src/lib/components/default-components/DefaultScribble.tsx +1 -1
- package/src/lib/components/default-components/DefaultShapeIndicator.tsx +5 -1
- package/src/lib/config/TLUserPreferences.ts +21 -1
- package/src/lib/editor/Editor.test.ts +102 -11
- package/src/lib/editor/Editor.ts +165 -198
- package/src/lib/editor/derivations/notVisibleShapes.ts +6 -0
- package/src/lib/editor/managers/ClickManager/ClickManager.test.ts +15 -14
- package/src/lib/editor/managers/EdgeScrollManager/EdgeScrollManager.test.ts +16 -15
- package/src/lib/editor/managers/FocusManager/FocusManager.test.ts +49 -48
- package/src/lib/editor/managers/FocusManager/FocusManager.ts +6 -2
- package/src/lib/editor/managers/FontManager/FontManager.test.ts +24 -23
- package/src/lib/editor/managers/HistoryManager/HistoryManager.test.ts +7 -6
- package/src/lib/editor/managers/ScribbleManager/ScribbleManager.test.ts +12 -11
- package/src/lib/editor/managers/SnapManager/SnapManager.test.ts +57 -50
- package/src/lib/editor/managers/TextManager/TextManager.test.ts +51 -26
- package/src/lib/editor/managers/TickManager/TickManager.test.ts +14 -13
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.test.ts +56 -26
- package/src/lib/editor/managers/UserPreferencesManager/UserPreferencesManager.ts +13 -1
- package/src/lib/editor/shapes/ShapeUtil.ts +46 -0
- package/src/lib/editor/types/misc-types.ts +54 -7
- package/src/lib/exports/getSvgJsx.test.ts +868 -0
- package/src/lib/exports/getSvgJsx.tsx +78 -21
- package/src/lib/hooks/useCanvasEvents.ts +62 -55
- package/src/lib/hooks/useDocumentEvents.ts +6 -6
- package/src/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.ts +1 -1
- package/src/lib/hooks/useGestureEvents.ts +2 -2
- package/src/lib/hooks/useHandleEvents.ts +6 -6
- package/src/lib/hooks/usePassThroughMouseOverEvents.ts +4 -1
- package/src/lib/hooks/usePassThroughWheelEvents.ts +6 -1
- package/src/lib/hooks/useSelectionEvents.ts +9 -14
- package/src/lib/hooks/useStateAttribute.ts +15 -0
- package/src/lib/license/LicenseManager.test.ts +724 -383
- package/src/lib/license/LicenseManager.ts +204 -58
- package/src/lib/license/LicenseProvider.tsx +74 -2
- package/src/lib/license/Watermark.test.tsx +2 -1
- package/src/lib/license/Watermark.tsx +152 -77
- package/src/lib/license/useLicenseManagerState.ts +2 -2
- package/src/lib/options.ts +8 -0
- package/src/lib/primitives/Box.test.ts +126 -0
- package/src/lib/primitives/Box.ts +10 -1
- package/src/lib/primitives/Vec.ts +0 -5
- package/src/lib/primitives/geometry/Geometry2d.test.ts +420 -0
- package/src/lib/primitives/geometry/Geometry2d.ts +78 -21
- package/src/lib/primitives/geometry/Group2d.ts +10 -1
- package/src/lib/test/InFrontOfTheCanvas.test.tsx +187 -0
- package/src/lib/utils/EditorAtom.ts +37 -0
- package/src/lib/utils/dom.test.ts +103 -0
- package/src/lib/utils/dom.ts +8 -1
- package/src/lib/utils/getPointerInfo.ts +3 -2
- package/src/lib/utils/reparenting.ts +10 -70
- package/src/lib/utils/sync/LocalIndexedDb.test.ts +2 -1
- package/src/lib/utils/sync/TLLocalSyncClient.test.ts +15 -15
- package/src/version.ts +4 -4
- package/dist-cjs/lib/utils/nearestMultiple.js.map +0 -7
- package/dist-esm/lib/utils/nearestMultiple.mjs +0 -14
- package/dist-esm/lib/utils/nearestMultiple.mjs.map +0 -7
- package/src/lib/utils/nearestMultiple.ts +0 -13
|
@@ -44,7 +44,7 @@ function useHandleEvents(id, handleId) {
|
|
|
44
44
|
const editor = (0, import_useEditor.useEditor)();
|
|
45
45
|
return React.useMemo(() => {
|
|
46
46
|
const onPointerDown = (e) => {
|
|
47
|
-
if (e
|
|
47
|
+
if (editor.wasEventAlreadyHandled(e)) return;
|
|
48
48
|
const target = (0, import_dom.loopToHtmlElement)(e.currentTarget);
|
|
49
49
|
(0, import_dom.setPointerCapture)(target, e);
|
|
50
50
|
const { shape, handle } = getHandle(editor, id, handleId);
|
|
@@ -55,12 +55,12 @@ function useHandleEvents(id, handleId) {
|
|
|
55
55
|
handle,
|
|
56
56
|
shape,
|
|
57
57
|
name: "pointer_down",
|
|
58
|
-
...(0, import_getPointerInfo.getPointerInfo)(e)
|
|
58
|
+
...(0, import_getPointerInfo.getPointerInfo)(editor, e)
|
|
59
59
|
});
|
|
60
60
|
};
|
|
61
61
|
let lastX, lastY;
|
|
62
62
|
const onPointerMove = (e) => {
|
|
63
|
-
if (e
|
|
63
|
+
if (editor.wasEventAlreadyHandled(e)) return;
|
|
64
64
|
if (e.clientX === lastX && e.clientY === lastY) return;
|
|
65
65
|
lastX = e.clientX;
|
|
66
66
|
lastY = e.clientY;
|
|
@@ -72,11 +72,11 @@ function useHandleEvents(id, handleId) {
|
|
|
72
72
|
handle,
|
|
73
73
|
shape,
|
|
74
74
|
name: "pointer_move",
|
|
75
|
-
...(0, import_getPointerInfo.getPointerInfo)(e)
|
|
75
|
+
...(0, import_getPointerInfo.getPointerInfo)(editor, e)
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
const onPointerUp = (e) => {
|
|
79
|
-
if (e
|
|
79
|
+
if (editor.wasEventAlreadyHandled(e)) return;
|
|
80
80
|
const target = (0, import_dom.loopToHtmlElement)(e.currentTarget);
|
|
81
81
|
(0, import_dom.releasePointerCapture)(target, e);
|
|
82
82
|
const { shape, handle } = getHandle(editor, id, handleId);
|
|
@@ -87,7 +87,7 @@ function useHandleEvents(id, handleId) {
|
|
|
87
87
|
handle,
|
|
88
88
|
shape,
|
|
89
89
|
name: "pointer_up",
|
|
90
|
-
...(0, import_getPointerInfo.getPointerInfo)(e)
|
|
90
|
+
...(0, import_getPointerInfo.getPointerInfo)(editor, e)
|
|
91
91
|
});
|
|
92
92
|
};
|
|
93
93
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/hooks/useHandleEvents.ts"],
|
|
4
|
-
"sourcesContent": ["import { TLArrowShape, TLLineShape, TLShapeId } from '@tldraw/tlschema'\nimport * as React from 'react'\nimport { Editor } from '../editor/Editor'\nimport { loopToHtmlElement, releasePointerCapture, setPointerCapture } from '../utils/dom'\nimport { getPointerInfo } from '../utils/getPointerInfo'\nimport { useEditor } from './useEditor'\n\nfunction getHandle(editor: Editor, id: TLShapeId, handleId: string) {\n\tconst shape = editor.getShape<TLArrowShape | TLLineShape>(id)!\n\tconst handles = editor.getShapeHandles(shape)!\n\treturn { shape, handle: handles.find((h) => h.id === handleId) }\n}\n\nexport function useHandleEvents(id: TLShapeId, handleId: string) {\n\tconst editor = useEditor()\n\n\treturn React.useMemo(() => {\n\t\tconst onPointerDown = (e: React.PointerEvent) => {\n\t\t\tif ((e
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,YAAuB;AAEvB,iBAA4E;AAC5E,4BAA+B;AAC/B,uBAA0B;AAE1B,SAAS,UAAU,QAAgB,IAAe,UAAkB;AACnE,QAAM,QAAQ,OAAO,SAAqC,EAAE;AAC5D,QAAM,UAAU,OAAO,gBAAgB,KAAK;AAC5C,SAAO,EAAE,OAAO,QAAQ,QAAQ,KAAK,CAAC,MAAM,EAAE,OAAO,QAAQ,EAAE;AAChE;AAEO,SAAS,gBAAgB,IAAe,UAAkB;AAChE,QAAM,aAAS,4BAAU;AAEzB,SAAO,MAAM,QAAQ,MAAM;AAC1B,UAAM,gBAAgB,CAAC,MAA0B;AAChD,
|
|
4
|
+
"sourcesContent": ["import { TLArrowShape, TLLineShape, TLShapeId } from '@tldraw/tlschema'\nimport * as React from 'react'\nimport { Editor } from '../editor/Editor'\nimport { loopToHtmlElement, releasePointerCapture, setPointerCapture } from '../utils/dom'\nimport { getPointerInfo } from '../utils/getPointerInfo'\nimport { useEditor } from './useEditor'\n\nfunction getHandle(editor: Editor, id: TLShapeId, handleId: string) {\n\tconst shape = editor.getShape<TLArrowShape | TLLineShape>(id)!\n\tconst handles = editor.getShapeHandles(shape)!\n\treturn { shape, handle: handles.find((h) => h.id === handleId) }\n}\n\nexport function useHandleEvents(id: TLShapeId, handleId: string) {\n\tconst editor = useEditor()\n\n\treturn React.useMemo(() => {\n\t\tconst onPointerDown = (e: React.PointerEvent) => {\n\t\t\tif (editor.wasEventAlreadyHandled(e)) return\n\n\t\t\t// Must set pointer capture on an HTML element!\n\t\t\tconst target = loopToHtmlElement(e.currentTarget)\n\t\t\tsetPointerCapture(target, e)\n\n\t\t\tconst { shape, handle } = getHandle(editor, id, handleId)\n\n\t\t\tif (!handle) return\n\n\t\t\teditor.dispatch({\n\t\t\t\ttype: 'pointer',\n\t\t\t\ttarget: 'handle',\n\t\t\t\thandle,\n\t\t\t\tshape,\n\t\t\t\tname: 'pointer_down',\n\t\t\t\t...getPointerInfo(editor, e),\n\t\t\t})\n\t\t}\n\n\t\t// Track the last screen point\n\t\tlet lastX: number, lastY: number\n\n\t\tconst onPointerMove = (e: React.PointerEvent) => {\n\t\t\tif (editor.wasEventAlreadyHandled(e)) return\n\t\t\tif (e.clientX === lastX && e.clientY === lastY) return\n\t\t\tlastX = e.clientX\n\t\t\tlastY = e.clientY\n\n\t\t\tconst { shape, handle } = getHandle(editor, id, handleId)\n\n\t\t\tif (!handle) return\n\n\t\t\teditor.dispatch({\n\t\t\t\ttype: 'pointer',\n\t\t\t\ttarget: 'handle',\n\t\t\t\thandle,\n\t\t\t\tshape,\n\t\t\t\tname: 'pointer_move',\n\t\t\t\t...getPointerInfo(editor, e),\n\t\t\t})\n\t\t}\n\n\t\tconst onPointerUp = (e: React.PointerEvent) => {\n\t\t\tif (editor.wasEventAlreadyHandled(e)) return\n\n\t\t\tconst target = loopToHtmlElement(e.currentTarget)\n\t\t\treleasePointerCapture(target, e)\n\n\t\t\tconst { shape, handle } = getHandle(editor, id, handleId)\n\n\t\t\tif (!handle) return\n\n\t\t\teditor.dispatch({\n\t\t\t\ttype: 'pointer',\n\t\t\t\ttarget: 'handle',\n\t\t\t\thandle,\n\t\t\t\tshape,\n\t\t\t\tname: 'pointer_up',\n\t\t\t\t...getPointerInfo(editor, e),\n\t\t\t})\n\t\t}\n\n\t\treturn {\n\t\t\tonPointerDown,\n\t\t\tonPointerMove,\n\t\t\tonPointerUp,\n\t\t}\n\t}, [editor, id, handleId])\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,YAAuB;AAEvB,iBAA4E;AAC5E,4BAA+B;AAC/B,uBAA0B;AAE1B,SAAS,UAAU,QAAgB,IAAe,UAAkB;AACnE,QAAM,QAAQ,OAAO,SAAqC,EAAE;AAC5D,QAAM,UAAU,OAAO,gBAAgB,KAAK;AAC5C,SAAO,EAAE,OAAO,QAAQ,QAAQ,KAAK,CAAC,MAAM,EAAE,OAAO,QAAQ,EAAE;AAChE;AAEO,SAAS,gBAAgB,IAAe,UAAkB;AAChE,QAAM,aAAS,4BAAU;AAEzB,SAAO,MAAM,QAAQ,MAAM;AAC1B,UAAM,gBAAgB,CAAC,MAA0B;AAChD,UAAI,OAAO,uBAAuB,CAAC,EAAG;AAGtC,YAAM,aAAS,8BAAkB,EAAE,aAAa;AAChD,wCAAkB,QAAQ,CAAC;AAE3B,YAAM,EAAE,OAAO,OAAO,IAAI,UAAU,QAAQ,IAAI,QAAQ;AAExD,UAAI,CAAC,OAAQ;AAEb,aAAO,SAAS;AAAA,QACf,MAAM;AAAA,QACN,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA,MAAM;AAAA,QACN,OAAG,sCAAe,QAAQ,CAAC;AAAA,MAC5B,CAAC;AAAA,IACF;AAGA,QAAI,OAAe;AAEnB,UAAM,gBAAgB,CAAC,MAA0B;AAChD,UAAI,OAAO,uBAAuB,CAAC,EAAG;AACtC,UAAI,EAAE,YAAY,SAAS,EAAE,YAAY,MAAO;AAChD,cAAQ,EAAE;AACV,cAAQ,EAAE;AAEV,YAAM,EAAE,OAAO,OAAO,IAAI,UAAU,QAAQ,IAAI,QAAQ;AAExD,UAAI,CAAC,OAAQ;AAEb,aAAO,SAAS;AAAA,QACf,MAAM;AAAA,QACN,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA,MAAM;AAAA,QACN,OAAG,sCAAe,QAAQ,CAAC;AAAA,MAC5B,CAAC;AAAA,IACF;AAEA,UAAM,cAAc,CAAC,MAA0B;AAC9C,UAAI,OAAO,uBAAuB,CAAC,EAAG;AAEtC,YAAM,aAAS,8BAAkB,EAAE,aAAa;AAChD,4CAAsB,QAAQ,CAAC;AAE/B,YAAM,EAAE,OAAO,OAAO,IAAI,UAAU,QAAQ,IAAI,QAAQ;AAExD,UAAI,CAAC,OAAQ;AAEb,aAAO,SAAS;AAAA,QACf,MAAM;AAAA,QACN,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA,MAAM;AAAA,QACN,OAAG,sCAAe,QAAQ,CAAC;AAAA,MAC5B,CAAC;AAAA,IACF;AAEA,WAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD,GAAG,CAAC,QAAQ,IAAI,QAAQ,CAAC;AAC1B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,11 +24,14 @@ module.exports = __toCommonJS(usePassThroughMouseOverEvents_exports);
|
|
|
24
24
|
var import_react = require("react");
|
|
25
25
|
var import_dom = require("../utils/dom");
|
|
26
26
|
var import_useContainer = require("./useContainer");
|
|
27
|
+
var import_useEditor = require("./useEditor");
|
|
27
28
|
function usePassThroughMouseOverEvents(ref) {
|
|
28
29
|
if (!ref) throw Error("usePassThroughWheelEvents must be passed a ref");
|
|
29
30
|
const container = (0, import_useContainer.useContainer)();
|
|
31
|
+
const editor = (0, import_useEditor.useMaybeEditor)();
|
|
30
32
|
(0, import_react.useEffect)(() => {
|
|
31
33
|
function onMouseOver(e) {
|
|
34
|
+
if (!editor?.getInstanceState().isFocused) return;
|
|
32
35
|
if (e.isSpecialRedispatchedEvent) return;
|
|
33
36
|
(0, import_dom.preventDefault)(e);
|
|
34
37
|
const cvs = container.querySelector(".tl-canvas");
|
|
@@ -43,6 +46,6 @@ function usePassThroughMouseOverEvents(ref) {
|
|
|
43
46
|
return () => {
|
|
44
47
|
elm.removeEventListener("mouseover", onMouseOver);
|
|
45
48
|
};
|
|
46
|
-
}, [container, ref]);
|
|
49
|
+
}, [container, editor, ref]);
|
|
47
50
|
}
|
|
48
51
|
//# sourceMappingURL=usePassThroughMouseOverEvents.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/hooks/usePassThroughMouseOverEvents.ts"],
|
|
4
|
-
"sourcesContent": ["import { RefObject, useEffect } from 'react'\nimport { preventDefault } from '../utils/dom'\nimport { useContainer } from './useContainer'\n\n/** @public */\nexport function usePassThroughMouseOverEvents(ref: RefObject<HTMLElement>) {\n\tif (!ref) throw Error('usePassThroughWheelEvents must be passed a ref')\n\tconst container = useContainer()\n\n\tuseEffect(() => {\n\t\tfunction onMouseOver(e: MouseEvent) {\n\t\t\tif ((e as any).isSpecialRedispatchedEvent) return\n\t\t\tpreventDefault(e)\n\t\t\tconst cvs = container.querySelector('.tl-canvas')\n\t\t\tif (!cvs) return\n\t\t\tconst newEvent = new PointerEvent(e.type, e as any)\n\t\t\t;(newEvent as any).isSpecialRedispatchedEvent = true\n\t\t\tcvs.dispatchEvent(newEvent)\n\t\t}\n\n\t\tconst elm = ref.current\n\t\tif (!elm) return\n\n\t\telm.addEventListener('mouseover', onMouseOver, { passive: false })\n\t\treturn () => {\n\t\t\telm.removeEventListener('mouseover', onMouseOver)\n\t\t}\n\t}, [container, ref])\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AACrC,iBAA+B;AAC/B,0BAA6B;
|
|
4
|
+
"sourcesContent": ["import { RefObject, useEffect } from 'react'\nimport { preventDefault } from '../utils/dom'\nimport { useContainer } from './useContainer'\nimport { useMaybeEditor } from './useEditor'\n\n/** @public */\nexport function usePassThroughMouseOverEvents(ref: RefObject<HTMLElement>) {\n\tif (!ref) throw Error('usePassThroughWheelEvents must be passed a ref')\n\tconst container = useContainer()\n\tconst editor = useMaybeEditor()\n\n\tuseEffect(() => {\n\t\tfunction onMouseOver(e: MouseEvent) {\n\t\t\tif (!editor?.getInstanceState().isFocused) return\n\t\t\tif ((e as any).isSpecialRedispatchedEvent) return\n\t\t\tpreventDefault(e)\n\t\t\tconst cvs = container.querySelector('.tl-canvas')\n\t\t\tif (!cvs) return\n\t\t\tconst newEvent = new PointerEvent(e.type, e as any)\n\t\t\t;(newEvent as any).isSpecialRedispatchedEvent = true\n\t\t\tcvs.dispatchEvent(newEvent)\n\t\t}\n\n\t\tconst elm = ref.current\n\t\tif (!elm) return\n\n\t\telm.addEventListener('mouseover', onMouseOver, { passive: false })\n\t\treturn () => {\n\t\t\telm.removeEventListener('mouseover', onMouseOver)\n\t\t}\n\t}, [container, editor, ref])\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AACrC,iBAA+B;AAC/B,0BAA6B;AAC7B,uBAA+B;AAGxB,SAAS,8BAA8B,KAA6B;AAC1E,MAAI,CAAC,IAAK,OAAM,MAAM,gDAAgD;AACtE,QAAM,gBAAY,kCAAa;AAC/B,QAAM,aAAS,iCAAe;AAE9B,8BAAU,MAAM;AACf,aAAS,YAAY,GAAe;AACnC,UAAI,CAAC,QAAQ,iBAAiB,EAAE,UAAW;AAC3C,UAAK,EAAU,2BAA4B;AAC3C,qCAAe,CAAC;AAChB,YAAM,MAAM,UAAU,cAAc,YAAY;AAChD,UAAI,CAAC,IAAK;AACV,YAAM,WAAW,IAAI,aAAa,EAAE,MAAM,CAAQ;AACjD,MAAC,SAAiB,6BAA6B;AAChD,UAAI,cAAc,QAAQ;AAAA,IAC3B;AAEA,UAAM,MAAM,IAAI;AAChB,QAAI,CAAC,IAAK;AAEV,QAAI,iBAAiB,aAAa,aAAa,EAAE,SAAS,MAAM,CAAC;AACjE,WAAO,MAAM;AACZ,UAAI,oBAAoB,aAAa,WAAW;AAAA,IACjD;AAAA,EACD,GAAG,CAAC,WAAW,QAAQ,GAAG,CAAC;AAC5B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,11 +24,14 @@ module.exports = __toCommonJS(usePassThroughWheelEvents_exports);
|
|
|
24
24
|
var import_react = require("react");
|
|
25
25
|
var import_dom = require("../utils/dom");
|
|
26
26
|
var import_useContainer = require("./useContainer");
|
|
27
|
+
var import_useEditor = require("./useEditor");
|
|
27
28
|
function usePassThroughWheelEvents(ref) {
|
|
28
29
|
if (!ref) throw Error("usePassThroughWheelEvents must be passed a ref");
|
|
29
30
|
const container = (0, import_useContainer.useContainer)();
|
|
31
|
+
const editor = (0, import_useEditor.useMaybeEditor)();
|
|
30
32
|
(0, import_react.useEffect)(() => {
|
|
31
33
|
function onWheel(e) {
|
|
34
|
+
if (!editor?.getInstanceState().isFocused) return;
|
|
32
35
|
if (e.isSpecialRedispatchedEvent) return;
|
|
33
36
|
const elm2 = ref.current;
|
|
34
37
|
if (elm2 && elm2.scrollHeight > elm2.clientHeight) {
|
|
@@ -47,6 +50,6 @@ function usePassThroughWheelEvents(ref) {
|
|
|
47
50
|
return () => {
|
|
48
51
|
elm.removeEventListener("wheel", onWheel);
|
|
49
52
|
};
|
|
50
|
-
}, [container, ref]);
|
|
53
|
+
}, [container, editor, ref]);
|
|
51
54
|
}
|
|
52
55
|
//# sourceMappingURL=usePassThroughWheelEvents.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/hooks/usePassThroughWheelEvents.ts"],
|
|
4
|
-
"sourcesContent": ["import { RefObject, useEffect } from 'react'\nimport { preventDefault } from '../utils/dom'\nimport { useContainer } from './useContainer'\n\n/** @public */\nexport function usePassThroughWheelEvents(ref: RefObject<HTMLElement>) {\n\tif (!ref) throw Error('usePassThroughWheelEvents must be passed a ref')\n\tconst container = useContainer()\n\n\tuseEffect(() => {\n\t\tfunction onWheel(e: WheelEvent) {\n\t\t\tif ((e as any).isSpecialRedispatchedEvent) return\n\n\t\t\t// if the element is scrollable, don't redispatch the event\n\t\t\tconst elm = ref.current\n\t\t\tif (elm && elm.scrollHeight > elm.clientHeight) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tpreventDefault(e)\n\t\t\tconst cvs = container.querySelector('.tl-canvas')\n\t\t\tif (!cvs) return\n\t\t\tconst newEvent = new WheelEvent('wheel', e as any)\n\t\t\t;(newEvent as any).isSpecialRedispatchedEvent = true\n\t\t\tcvs.dispatchEvent(newEvent)\n\t\t}\n\n\t\tconst elm = ref.current\n\t\tif (!elm) return\n\n\t\telm.addEventListener('wheel', onWheel, { passive: false })\n\t\treturn () => {\n\t\t\telm.removeEventListener('wheel', onWheel)\n\t\t}\n\t}, [container, ref])\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AACrC,iBAA+B;AAC/B,0BAA6B;
|
|
4
|
+
"sourcesContent": ["import { RefObject, useEffect } from 'react'\nimport { preventDefault } from '../utils/dom'\nimport { useContainer } from './useContainer'\nimport { useMaybeEditor } from './useEditor'\n\n/** @public */\nexport function usePassThroughWheelEvents(ref: RefObject<HTMLElement>) {\n\tif (!ref) throw Error('usePassThroughWheelEvents must be passed a ref')\n\tconst container = useContainer()\n\tconst editor = useMaybeEditor()\n\n\tuseEffect(() => {\n\t\tfunction onWheel(e: WheelEvent) {\n\t\t\t// Only pass through wheel events if the editor is focused\n\t\t\tif (!editor?.getInstanceState().isFocused) return\n\n\t\t\tif ((e as any).isSpecialRedispatchedEvent) return\n\n\t\t\t// if the element is scrollable, don't redispatch the event\n\t\t\tconst elm = ref.current\n\t\t\tif (elm && elm.scrollHeight > elm.clientHeight) {\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tpreventDefault(e)\n\t\t\tconst cvs = container.querySelector('.tl-canvas')\n\t\t\tif (!cvs) return\n\t\t\tconst newEvent = new WheelEvent('wheel', e as any)\n\t\t\t;(newEvent as any).isSpecialRedispatchedEvent = true\n\t\t\tcvs.dispatchEvent(newEvent)\n\t\t}\n\n\t\tconst elm = ref.current\n\t\tif (!elm) return\n\n\t\telm.addEventListener('wheel', onWheel, { passive: false })\n\t\treturn () => {\n\t\t\telm.removeEventListener('wheel', onWheel)\n\t\t}\n\t}, [container, editor, ref])\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AACrC,iBAA+B;AAC/B,0BAA6B;AAC7B,uBAA+B;AAGxB,SAAS,0BAA0B,KAA6B;AACtE,MAAI,CAAC,IAAK,OAAM,MAAM,gDAAgD;AACtE,QAAM,gBAAY,kCAAa;AAC/B,QAAM,aAAS,iCAAe;AAE9B,8BAAU,MAAM;AACf,aAAS,QAAQ,GAAe;AAE/B,UAAI,CAAC,QAAQ,iBAAiB,EAAE,UAAW;AAE3C,UAAK,EAAU,2BAA4B;AAG3C,YAAMA,OAAM,IAAI;AAChB,UAAIA,QAAOA,KAAI,eAAeA,KAAI,cAAc;AAC/C;AAAA,MACD;AAEA,qCAAe,CAAC;AAChB,YAAM,MAAM,UAAU,cAAc,YAAY;AAChD,UAAI,CAAC,IAAK;AACV,YAAM,WAAW,IAAI,WAAW,SAAS,CAAQ;AAChD,MAAC,SAAiB,6BAA6B;AAChD,UAAI,cAAc,QAAQ;AAAA,IAC3B;AAEA,UAAM,MAAM,IAAI;AAChB,QAAI,CAAC,IAAK;AAEV,QAAI,iBAAiB,SAAS,SAAS,EAAE,SAAS,MAAM,CAAC;AACzD,WAAO,MAAM;AACZ,UAAI,oBAAoB,SAAS,OAAO;AAAA,IACzC;AAAA,EACD,GAAG,CAAC,WAAW,QAAQ,GAAG,CAAC;AAC5B;",
|
|
6
6
|
"names": ["elm"]
|
|
7
7
|
}
|
|
@@ -31,14 +31,14 @@ function useSelectionEvents(handle) {
|
|
|
31
31
|
const events = (0, import_react.useMemo)(
|
|
32
32
|
function selectionEvents() {
|
|
33
33
|
const onPointerDown = (e) => {
|
|
34
|
-
if (e
|
|
34
|
+
if (editor.wasEventAlreadyHandled(e)) return;
|
|
35
35
|
if (e.button === import_constants.RIGHT_MOUSE_BUTTON) {
|
|
36
36
|
editor.dispatch({
|
|
37
37
|
type: "pointer",
|
|
38
38
|
target: "selection",
|
|
39
39
|
handle,
|
|
40
40
|
name: "right_click",
|
|
41
|
-
...(0, import_getPointerInfo.getPointerInfo)(e)
|
|
41
|
+
...(0, import_getPointerInfo.getPointerInfo)(editor, e)
|
|
42
42
|
});
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
@@ -55,13 +55,13 @@ function useSelectionEvents(handle) {
|
|
|
55
55
|
type: "pointer",
|
|
56
56
|
target: "selection",
|
|
57
57
|
handle,
|
|
58
|
-
...(0, import_getPointerInfo.getPointerInfo)(e)
|
|
58
|
+
...(0, import_getPointerInfo.getPointerInfo)(editor, e)
|
|
59
59
|
});
|
|
60
|
-
|
|
60
|
+
editor.markEventAsHandled(e);
|
|
61
61
|
};
|
|
62
62
|
let lastX, lastY;
|
|
63
63
|
function onPointerMove(e) {
|
|
64
|
-
if (e
|
|
64
|
+
if (editor.wasEventAlreadyHandled(e)) return;
|
|
65
65
|
if (e.button !== 0) return;
|
|
66
66
|
if (e.clientX === lastX && e.clientY === lastY) return;
|
|
67
67
|
lastX = e.clientX;
|
|
@@ -71,18 +71,18 @@ function useSelectionEvents(handle) {
|
|
|
71
71
|
type: "pointer",
|
|
72
72
|
target: "selection",
|
|
73
73
|
handle,
|
|
74
|
-
...(0, import_getPointerInfo.getPointerInfo)(e)
|
|
74
|
+
...(0, import_getPointerInfo.getPointerInfo)(editor, e)
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
const onPointerUp = (e) => {
|
|
78
|
-
if (e
|
|
78
|
+
if (editor.wasEventAlreadyHandled(e)) return;
|
|
79
79
|
if (e.button !== 0) return;
|
|
80
80
|
editor.dispatch({
|
|
81
81
|
name: "pointer_up",
|
|
82
82
|
type: "pointer",
|
|
83
83
|
target: "selection",
|
|
84
84
|
handle,
|
|
85
|
-
...(0, import_getPointerInfo.getPointerInfo)(e)
|
|
85
|
+
...(0, import_getPointerInfo.getPointerInfo)(editor, e)
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
88
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/hooks/useSelectionEvents.ts"],
|
|
4
|
-
"sourcesContent": ["import { useMemo } from 'react'\nimport { RIGHT_MOUSE_BUTTON } from '../constants'\nimport { TLSelectionHandle } from '../editor/types/selection-types'\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwB;AACxB,uBAAmC;AAEnC,
|
|
4
|
+
"sourcesContent": ["import { useMemo } from 'react'\nimport { RIGHT_MOUSE_BUTTON } from '../constants'\nimport { TLSelectionHandle } from '../editor/types/selection-types'\nimport { loopToHtmlElement, releasePointerCapture, setPointerCapture } from '../utils/dom'\nimport { getPointerInfo } from '../utils/getPointerInfo'\nimport { useEditor } from './useEditor'\n\n/** @public */\nexport function useSelectionEvents(handle: TLSelectionHandle) {\n\tconst editor = useEditor()\n\n\tconst events = useMemo(\n\t\tfunction selectionEvents() {\n\t\t\tconst onPointerDown: React.PointerEventHandler = (e) => {\n\t\t\t\tif (editor.wasEventAlreadyHandled(e)) return\n\n\t\t\t\tif (e.button === RIGHT_MOUSE_BUTTON) {\n\t\t\t\t\teditor.dispatch({\n\t\t\t\t\t\ttype: 'pointer',\n\t\t\t\t\t\ttarget: 'selection',\n\t\t\t\t\t\thandle,\n\t\t\t\t\t\tname: 'right_click',\n\t\t\t\t\t\t...getPointerInfo(editor, e),\n\t\t\t\t\t})\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\tif (e.button !== 0) return\n\n\t\t\t\t// Because the events are probably set on SVG elements,\n\t\t\t\t// we need to instead place pointer capture on the first HTML\n\t\t\t\t// element above the event's target; and set a listener to\n\t\t\t\t// remove pointer capture when the pointer is released.\n\n\t\t\t\tconst elm = loopToHtmlElement(e.currentTarget)\n\n\t\t\t\tfunction releaseCapture() {\n\t\t\t\t\telm.removeEventListener('pointerup', releaseCapture)\n\t\t\t\t\treleasePointerCapture(elm, e)\n\t\t\t\t}\n\n\t\t\t\tsetPointerCapture(elm, e)\n\t\t\t\telm.addEventListener('pointerup', releaseCapture)\n\n\t\t\t\teditor.dispatch({\n\t\t\t\t\tname: 'pointer_down',\n\t\t\t\t\ttype: 'pointer',\n\t\t\t\t\ttarget: 'selection',\n\t\t\t\t\thandle,\n\t\t\t\t\t...getPointerInfo(editor, e),\n\t\t\t\t})\n\t\t\t\teditor.markEventAsHandled(e)\n\t\t\t}\n\n\t\t\t// Track the last screen point\n\t\t\tlet lastX: number, lastY: number\n\n\t\t\tfunction onPointerMove(e: React.PointerEvent) {\n\t\t\t\tif (editor.wasEventAlreadyHandled(e)) return\n\t\t\t\tif (e.button !== 0) return\n\t\t\t\tif (e.clientX === lastX && e.clientY === lastY) return\n\t\t\t\tlastX = e.clientX\n\t\t\t\tlastY = e.clientY\n\n\t\t\t\teditor.dispatch({\n\t\t\t\t\tname: 'pointer_move',\n\t\t\t\t\ttype: 'pointer',\n\t\t\t\t\ttarget: 'selection',\n\t\t\t\t\thandle,\n\t\t\t\t\t...getPointerInfo(editor, e),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tconst onPointerUp: React.PointerEventHandler = (e) => {\n\t\t\t\tif (editor.wasEventAlreadyHandled(e)) return\n\t\t\t\tif (e.button !== 0) return\n\n\t\t\t\teditor.dispatch({\n\t\t\t\t\tname: 'pointer_up',\n\t\t\t\t\ttype: 'pointer',\n\t\t\t\t\ttarget: 'selection',\n\t\t\t\t\thandle,\n\t\t\t\t\t...getPointerInfo(editor, e),\n\t\t\t\t})\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tonPointerDown,\n\t\t\t\tonPointerMove,\n\t\t\t\tonPointerUp,\n\t\t\t}\n\t\t},\n\t\t[editor, handle]\n\t)\n\n\treturn events\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAwB;AACxB,uBAAmC;AAEnC,iBAA4E;AAC5E,4BAA+B;AAC/B,uBAA0B;AAGnB,SAAS,mBAAmB,QAA2B;AAC7D,QAAM,aAAS,4BAAU;AAEzB,QAAM,aAAS;AAAA,IACd,SAAS,kBAAkB;AAC1B,YAAM,gBAA2C,CAAC,MAAM;AACvD,YAAI,OAAO,uBAAuB,CAAC,EAAG;AAEtC,YAAI,EAAE,WAAW,qCAAoB;AACpC,iBAAO,SAAS;AAAA,YACf,MAAM;AAAA,YACN,QAAQ;AAAA,YACR;AAAA,YACA,MAAM;AAAA,YACN,OAAG,sCAAe,QAAQ,CAAC;AAAA,UAC5B,CAAC;AACD;AAAA,QACD;AAEA,YAAI,EAAE,WAAW,EAAG;AAOpB,cAAM,UAAM,8BAAkB,EAAE,aAAa;AAE7C,iBAAS,iBAAiB;AACzB,cAAI,oBAAoB,aAAa,cAAc;AACnD,gDAAsB,KAAK,CAAC;AAAA,QAC7B;AAEA,0CAAkB,KAAK,CAAC;AACxB,YAAI,iBAAiB,aAAa,cAAc;AAEhD,eAAO,SAAS;AAAA,UACf,MAAM;AAAA,UACN,MAAM;AAAA,UACN,QAAQ;AAAA,UACR;AAAA,UACA,OAAG,sCAAe,QAAQ,CAAC;AAAA,QAC5B,CAAC;AACD,eAAO,mBAAmB,CAAC;AAAA,MAC5B;AAGA,UAAI,OAAe;AAEnB,eAAS,cAAc,GAAuB;AAC7C,YAAI,OAAO,uBAAuB,CAAC,EAAG;AACtC,YAAI,EAAE,WAAW,EAAG;AACpB,YAAI,EAAE,YAAY,SAAS,EAAE,YAAY,MAAO;AAChD,gBAAQ,EAAE;AACV,gBAAQ,EAAE;AAEV,eAAO,SAAS;AAAA,UACf,MAAM;AAAA,UACN,MAAM;AAAA,UACN,QAAQ;AAAA,UACR;AAAA,UACA,OAAG,sCAAe,QAAQ,CAAC;AAAA,QAC5B,CAAC;AAAA,MACF;AAEA,YAAM,cAAyC,CAAC,MAAM;AACrD,YAAI,OAAO,uBAAuB,CAAC,EAAG;AACtC,YAAI,EAAE,WAAW,EAAG;AAEpB,eAAO,SAAS;AAAA,UACf,MAAM;AAAA,UACN,MAAM;AAAA,UACN,QAAQ;AAAA,UACR;AAAA,UACA,OAAG,sCAAe,QAAQ,CAAC;AAAA,QAC5B,CAAC;AAAA,MACF;AAEA,aAAO;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAC,QAAQ,MAAM;AAAA,EAChB;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -16,19 +16,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var useStateAttribute_exports = {};
|
|
20
|
+
__export(useStateAttribute_exports, {
|
|
21
|
+
useStateAttribute: () => useStateAttribute
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
module.exports = __toCommonJS(useStateAttribute_exports);
|
|
24
|
+
var import_state = require("@tldraw/state");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_useEditor = require("./useEditor");
|
|
27
|
+
function useStateAttribute() {
|
|
28
|
+
const editor = (0, import_useEditor.useEditor)();
|
|
29
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
30
|
+
return (0, import_state.react)("stateAttribute", () => {
|
|
31
|
+
editor.getContainer().setAttribute("data-state", editor.getPath());
|
|
32
|
+
});
|
|
33
|
+
}, [editor]);
|
|
26
34
|
}
|
|
27
|
-
|
|
28
|
-
const decimal = float.toString().split(".")[1];
|
|
29
|
-
if (!decimal) return 1;
|
|
30
|
-
const denominator = Math.pow(10, decimal.length);
|
|
31
|
-
const numerator = parseInt(decimal, 10);
|
|
32
|
-
return denominator / gcd(numerator, denominator);
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=nearestMultiple.js.map
|
|
35
|
+
//# sourceMappingURL=useStateAttribute.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/hooks/useStateAttribute.ts"],
|
|
4
|
+
"sourcesContent": ["import { react } from '@tldraw/state'\nimport { useLayoutEffect } from 'react'\nimport { useEditor } from './useEditor'\n\nexport function useStateAttribute() {\n\tconst editor = useEditor()\n\n\t// we use a layout effect because we don't want there to be any perceptible delay between the\n\t// editor mounting and this attribute being applied, because styles may depend on it:\n\tuseLayoutEffect(() => {\n\t\treturn react('stateAttribute', () => {\n\t\t\teditor.getContainer().setAttribute('data-state', editor.getPath())\n\t\t})\n\t}, [editor])\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsB;AACtB,mBAAgC;AAChC,uBAA0B;AAEnB,SAAS,oBAAoB;AACnC,QAAM,aAAS,4BAAU;AAIzB,oCAAgB,MAAM;AACrB,eAAO,oBAAM,kBAAkB,MAAM;AACpC,aAAO,aAAa,EAAE,aAAa,cAAc,OAAO,QAAQ,CAAC;AAAA,IAClE,CAAC;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AACZ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -21,20 +21,30 @@ __export(LicenseManager_exports, {
|
|
|
21
21
|
FLAGS: () => FLAGS,
|
|
22
22
|
LicenseManager: () => LicenseManager,
|
|
23
23
|
PROPERTIES: () => PROPERTIES,
|
|
24
|
-
|
|
24
|
+
getLicenseState: () => getLicenseState
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(LicenseManager_exports);
|
|
27
27
|
var import_state = require("@tldraw/state");
|
|
28
|
-
var import_utils = require("@tldraw/utils");
|
|
29
28
|
var import_version = require("../../version");
|
|
30
29
|
var import_assets = require("../utils/assets");
|
|
31
30
|
var import_licensing = require("../utils/licensing");
|
|
32
|
-
const GRACE_PERIOD_DAYS =
|
|
31
|
+
const GRACE_PERIOD_DAYS = 30;
|
|
33
32
|
const FLAGS = {
|
|
33
|
+
// -- MUTUALLY EXCLUSIVE FLAGS --
|
|
34
|
+
// Annual means the license expires after a time period, usually 1 year.
|
|
34
35
|
ANNUAL_LICENSE: 1,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
// Perpetual means the license never expires up to the max supported version.
|
|
37
|
+
PERPETUAL_LICENSE: 1 << 1,
|
|
38
|
+
// -- ADDITIVE FLAGS --
|
|
39
|
+
// Internal means the license is for internal use only.
|
|
40
|
+
INTERNAL_LICENSE: 1 << 2,
|
|
41
|
+
// Watermark means the product is watermarked.
|
|
42
|
+
WITH_WATERMARK: 1 << 3,
|
|
43
|
+
// Evaluation means the license is for evaluation purposes only.
|
|
44
|
+
EVALUATION_LICENSE: 1 << 4,
|
|
45
|
+
// Native means the license is for native apps which switches
|
|
46
|
+
// on special-case logic.
|
|
47
|
+
NATIVE_LICENSE: 1 << 5
|
|
38
48
|
};
|
|
39
49
|
const HIGHEST_FLAG = Math.max(...Object.values(FLAGS));
|
|
40
50
|
const PROPERTIES = {
|
|
@@ -51,10 +61,7 @@ class LicenseManager {
|
|
|
51
61
|
isDevelopment;
|
|
52
62
|
isTest;
|
|
53
63
|
isCryptoAvailable;
|
|
54
|
-
state = (0, import_state.atom)(
|
|
55
|
-
"license state",
|
|
56
|
-
"pending"
|
|
57
|
-
);
|
|
64
|
+
state = (0, import_state.atom)("license state", "pending");
|
|
58
65
|
verbose = true;
|
|
59
66
|
constructor(licenseKey, testPublicKey, testEnvironment) {
|
|
60
67
|
this.isTest = process.env.NODE_ENV === "test";
|
|
@@ -62,17 +69,16 @@ class LicenseManager {
|
|
|
62
69
|
this.publicKey = testPublicKey || this.publicKey;
|
|
63
70
|
this.isCryptoAvailable = !!crypto.subtle;
|
|
64
71
|
this.getLicenseFromKey(licenseKey).then((result) => {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
72
|
+
const licenseState = getLicenseState(
|
|
73
|
+
result,
|
|
74
|
+
(messages) => this.outputMessages(messages),
|
|
75
|
+
this.isDevelopment
|
|
76
|
+
);
|
|
77
|
+
this.maybeTrack(result, licenseState);
|
|
78
|
+
this.state.set(licenseState);
|
|
79
|
+
}).catch((error) => {
|
|
80
|
+
console.error("License validation failed:", error);
|
|
81
|
+
this.state.set("unlicensed");
|
|
76
82
|
});
|
|
77
83
|
}
|
|
78
84
|
getIsDevelopment(testEnvironment) {
|
|
@@ -80,6 +86,37 @@ class LicenseManager {
|
|
|
80
86
|
if (testEnvironment === "production") return false;
|
|
81
87
|
return !["https:", "vscode-webview:"].includes(window.location.protocol) || window.location.hostname === "localhost";
|
|
82
88
|
}
|
|
89
|
+
getTrackType(result, licenseState) {
|
|
90
|
+
if (licenseState === "unlicensed-production") {
|
|
91
|
+
return "unlicensed";
|
|
92
|
+
}
|
|
93
|
+
if (this.isDevelopment) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
if (!result.isLicenseParseable) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
if (result.isEvaluationLicense) {
|
|
100
|
+
return "evaluation";
|
|
101
|
+
}
|
|
102
|
+
if (licenseState === "licensed-with-watermark") {
|
|
103
|
+
return "with_watermark";
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
maybeTrack(result, licenseState) {
|
|
108
|
+
const trackType = this.getTrackType(result, licenseState);
|
|
109
|
+
if (!trackType) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const url = new URL(WATERMARK_TRACK_SRC);
|
|
113
|
+
url.searchParams.set("version", import_version.version);
|
|
114
|
+
url.searchParams.set("license_type", trackType);
|
|
115
|
+
if ("license" in result) {
|
|
116
|
+
url.searchParams.set("license_id", result.license.id);
|
|
117
|
+
}
|
|
118
|
+
fetch(url.toString());
|
|
119
|
+
}
|
|
83
120
|
async extractLicenseKey(licenseKey) {
|
|
84
121
|
const [data, signature] = licenseKey.split(".");
|
|
85
122
|
const [prefix, encodedData] = data.split("/");
|
|
@@ -147,6 +184,8 @@ class LicenseManager {
|
|
|
147
184
|
const expiryDate = new Date(licenseInfo.expiryDate);
|
|
148
185
|
const isAnnualLicense = this.isFlagEnabled(licenseInfo.flags, FLAGS.ANNUAL_LICENSE);
|
|
149
186
|
const isPerpetualLicense = this.isFlagEnabled(licenseInfo.flags, FLAGS.PERPETUAL_LICENSE);
|
|
187
|
+
const isEvaluationLicense = this.isFlagEnabled(licenseInfo.flags, FLAGS.EVALUATION_LICENSE);
|
|
188
|
+
const daysSinceExpiry = this.getDaysSinceExpiry(expiryDate);
|
|
150
189
|
const result = {
|
|
151
190
|
license: licenseInfo,
|
|
152
191
|
isLicenseParseable: true,
|
|
@@ -158,7 +197,11 @@ class LicenseManager {
|
|
|
158
197
|
isPerpetualLicense,
|
|
159
198
|
isPerpetualLicenseExpired: isPerpetualLicense && this.isPerpetualLicenseExpired(expiryDate),
|
|
160
199
|
isInternalLicense: this.isFlagEnabled(licenseInfo.flags, FLAGS.INTERNAL_LICENSE),
|
|
161
|
-
|
|
200
|
+
isNativeLicense: this.isNativeLicense(licenseInfo),
|
|
201
|
+
isLicensedWithWatermark: this.isFlagEnabled(licenseInfo.flags, FLAGS.WITH_WATERMARK),
|
|
202
|
+
isEvaluationLicense,
|
|
203
|
+
isEvaluationLicenseExpired: isEvaluationLicense && this.isEvaluationLicenseExpired(expiryDate),
|
|
204
|
+
daysSinceExpiry
|
|
162
205
|
};
|
|
163
206
|
this.outputLicenseInfoIfNeeded(result);
|
|
164
207
|
return result;
|
|
@@ -170,13 +213,16 @@ class LicenseManager {
|
|
|
170
213
|
isDomainValid(licenseInfo) {
|
|
171
214
|
const currentHostname = window.location.hostname.toLowerCase();
|
|
172
215
|
return licenseInfo.hosts.some((host) => {
|
|
173
|
-
const
|
|
174
|
-
if (
|
|
216
|
+
const normalizedHostOrUrlRegex = host.toLowerCase().trim();
|
|
217
|
+
if (normalizedHostOrUrlRegex === currentHostname || `www.${normalizedHostOrUrlRegex}` === currentHostname || normalizedHostOrUrlRegex === `www.${currentHostname}`) {
|
|
175
218
|
return true;
|
|
176
219
|
}
|
|
177
220
|
if (host === "*") {
|
|
178
221
|
return true;
|
|
179
222
|
}
|
|
223
|
+
if (this.isNativeLicense(licenseInfo)) {
|
|
224
|
+
return new RegExp(normalizedHostOrUrlRegex).test(window.location.href);
|
|
225
|
+
}
|
|
180
226
|
if (host.includes("*")) {
|
|
181
227
|
const globToRegex = new RegExp(host.replace(/\*/g, ".*?"));
|
|
182
228
|
return globToRegex.test(currentHostname) || globToRegex.test(`www.${currentHostname}`);
|
|
@@ -184,13 +230,16 @@ class LicenseManager {
|
|
|
184
230
|
if (window.location.protocol === "vscode-webview:") {
|
|
185
231
|
const currentUrl = new URL(window.location.href);
|
|
186
232
|
const extensionId = currentUrl.searchParams.get("extensionId");
|
|
187
|
-
if (
|
|
233
|
+
if (normalizedHostOrUrlRegex === extensionId) {
|
|
188
234
|
return true;
|
|
189
235
|
}
|
|
190
236
|
}
|
|
191
237
|
return false;
|
|
192
238
|
});
|
|
193
239
|
}
|
|
240
|
+
isNativeLicense(licenseInfo) {
|
|
241
|
+
return this.isFlagEnabled(licenseInfo.flags, FLAGS.NATIVE_LICENSE);
|
|
242
|
+
}
|
|
194
243
|
getExpirationDateWithoutGracePeriod(expiryDate) {
|
|
195
244
|
return new Date(expiryDate.getFullYear(), expiryDate.getMonth(), expiryDate.getDate());
|
|
196
245
|
}
|
|
@@ -204,14 +253,7 @@ class LicenseManager {
|
|
|
204
253
|
}
|
|
205
254
|
isAnnualLicenseExpired(expiryDate) {
|
|
206
255
|
const expiration = this.getExpirationDateWithGracePeriod(expiryDate);
|
|
207
|
-
|
|
208
|
-
if (!isExpired && /* @__PURE__ */ new Date() >= this.getExpirationDateWithoutGracePeriod(expiryDate)) {
|
|
209
|
-
this.outputMessages([
|
|
210
|
-
"tldraw license is about to expire, you are in a grace period.",
|
|
211
|
-
`Please reach out to ${LICENSE_EMAIL} if you would like to renew your license.`
|
|
212
|
-
]);
|
|
213
|
-
}
|
|
214
|
-
return isExpired;
|
|
256
|
+
return /* @__PURE__ */ new Date() >= expiration;
|
|
215
257
|
}
|
|
216
258
|
isPerpetualLicenseExpired(expiryDate) {
|
|
217
259
|
const expiration = this.getExpirationDateWithGracePeriod(expiryDate);
|
|
@@ -221,6 +263,18 @@ class LicenseManager {
|
|
|
221
263
|
};
|
|
222
264
|
return dates.major >= expiration || dates.minor >= expiration;
|
|
223
265
|
}
|
|
266
|
+
getDaysSinceExpiry(expiryDate) {
|
|
267
|
+
const now = /* @__PURE__ */ new Date();
|
|
268
|
+
const expiration = this.getExpirationDateWithoutGracePeriod(expiryDate);
|
|
269
|
+
const diffTime = now.getTime() - expiration.getTime();
|
|
270
|
+
const diffDays = Math.floor(diffTime / (1e3 * 60 * 60 * 24));
|
|
271
|
+
return Math.max(0, diffDays);
|
|
272
|
+
}
|
|
273
|
+
isEvaluationLicenseExpired(expiryDate) {
|
|
274
|
+
const now = /* @__PURE__ */ new Date();
|
|
275
|
+
const expiration = this.getExpirationDateWithoutGracePeriod(expiryDate);
|
|
276
|
+
return now >= expiration;
|
|
277
|
+
}
|
|
224
278
|
isFlagEnabled(flags, flag) {
|
|
225
279
|
return (flags & flag) === flag;
|
|
226
280
|
}
|
|
@@ -230,18 +284,6 @@ class LicenseManager {
|
|
|
230
284
|
this.outputMessages(["Invalid tldraw license key", `Reason: ${msg}`]);
|
|
231
285
|
}
|
|
232
286
|
outputLicenseInfoIfNeeded(result) {
|
|
233
|
-
if (result.isAnnualLicenseExpired) {
|
|
234
|
-
this.outputMessages([
|
|
235
|
-
"Your tldraw license has expired!",
|
|
236
|
-
`Please reach out to ${LICENSE_EMAIL} to renew.`
|
|
237
|
-
]);
|
|
238
|
-
}
|
|
239
|
-
if (!result.isDomainValid && !result.isDevelopment) {
|
|
240
|
-
this.outputMessages([
|
|
241
|
-
"This tldraw license key is not valid for this domain!",
|
|
242
|
-
`Please reach out to ${LICENSE_EMAIL} if you would like to use tldraw on other domains.`
|
|
243
|
-
]);
|
|
244
|
-
}
|
|
245
287
|
if (result.license.flags >= HIGHEST_FLAG * 2) {
|
|
246
288
|
this.outputMessages([
|
|
247
289
|
"This tldraw license contains some unknown flags.",
|
|
@@ -270,15 +312,63 @@ class LicenseManager {
|
|
|
270
312
|
}
|
|
271
313
|
static className = "tl-watermark_SEE-LICENSE";
|
|
272
314
|
}
|
|
273
|
-
function
|
|
274
|
-
if (!result.isLicenseParseable)
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
315
|
+
function getLicenseState(result, outputMessages, isDevelopment) {
|
|
316
|
+
if (!result.isLicenseParseable) {
|
|
317
|
+
if (isDevelopment) {
|
|
318
|
+
return "unlicensed";
|
|
319
|
+
}
|
|
320
|
+
if (result.reason === "no-key-provided") {
|
|
321
|
+
outputMessages([
|
|
322
|
+
"No tldraw license key provided!",
|
|
323
|
+
"A license is required for production deployments.",
|
|
324
|
+
`Please reach out to ${LICENSE_EMAIL} to purchase a license.`
|
|
325
|
+
]);
|
|
326
|
+
} else {
|
|
327
|
+
outputMessages([
|
|
328
|
+
"Invalid license key. tldraw requires a valid license for production use.",
|
|
329
|
+
`Please reach out to ${LICENSE_EMAIL} to purchase a license.`
|
|
330
|
+
]);
|
|
331
|
+
}
|
|
332
|
+
return "unlicensed-production";
|
|
333
|
+
}
|
|
334
|
+
if (!result.isDomainValid && !result.isDevelopment) {
|
|
335
|
+
outputMessages([
|
|
336
|
+
"License key is not valid for this domain.",
|
|
337
|
+
"A license is required for production deployments.",
|
|
338
|
+
`Please reach out to ${LICENSE_EMAIL} to purchase a license.`
|
|
339
|
+
]);
|
|
340
|
+
return "unlicensed-production";
|
|
341
|
+
}
|
|
342
|
+
if (result.isEvaluationLicense) {
|
|
343
|
+
if (result.isEvaluationLicenseExpired) {
|
|
344
|
+
outputMessages([
|
|
345
|
+
"Your tldraw evaluation license has expired!",
|
|
346
|
+
`Please reach out to ${LICENSE_EMAIL} to purchase a full license.`
|
|
347
|
+
]);
|
|
348
|
+
return "expired";
|
|
349
|
+
} else {
|
|
350
|
+
return "licensed";
|
|
279
351
|
}
|
|
280
|
-
return true;
|
|
281
352
|
}
|
|
282
|
-
|
|
353
|
+
if (result.isPerpetualLicenseExpired || result.isAnnualLicenseExpired) {
|
|
354
|
+
outputMessages([
|
|
355
|
+
"Your tldraw license has been expired for more than 30 days!",
|
|
356
|
+
`Please reach out to ${LICENSE_EMAIL} to renew your license.`
|
|
357
|
+
]);
|
|
358
|
+
return "expired";
|
|
359
|
+
}
|
|
360
|
+
const daysSinceExpiry = result.daysSinceExpiry;
|
|
361
|
+
if (daysSinceExpiry > 0 && !result.isEvaluationLicense) {
|
|
362
|
+
outputMessages([
|
|
363
|
+
"Your tldraw license has expired.",
|
|
364
|
+
`License expired ${daysSinceExpiry} days ago.`,
|
|
365
|
+
`Please reach out to ${LICENSE_EMAIL} to renew your license.`
|
|
366
|
+
]);
|
|
367
|
+
return "licensed";
|
|
368
|
+
}
|
|
369
|
+
if (result.isLicensedWithWatermark) {
|
|
370
|
+
return "licensed-with-watermark";
|
|
371
|
+
}
|
|
372
|
+
return "licensed";
|
|
283
373
|
}
|
|
284
374
|
//# sourceMappingURL=LicenseManager.js.map
|