@excalidraw/common 0.18.0-3a5ef40 → 0.18.0-3c916c5
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/dev/index.js +536 -119
- package/dist/dev/index.js.map +4 -4
- package/dist/prod/index.js +3 -3
- package/dist/types/common/debug.d.ts +21 -0
- package/dist/types/common/src/appEventBus.d.ts +27 -0
- package/dist/types/common/src/colors.d.ts +36 -14
- package/dist/types/common/src/constants.d.ts +66 -7
- package/dist/types/common/src/index.d.ts +3 -0
- package/dist/types/common/src/keys.d.ts +4 -0
- package/dist/types/common/src/points.d.ts +1 -1
- package/dist/types/common/src/random.d.ts +7 -0
- package/dist/types/common/src/utils.d.ts +16 -50
- package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
- package/dist/types/element/src/Scene.d.ts +9 -5
- package/dist/types/element/src/align.d.ts +5 -2
- package/dist/types/element/src/arrowEndpointText.d.ts +49 -0
- package/dist/types/element/src/arrowheads.d.ts +3 -0
- package/dist/types/element/src/arrows/focus.d.ts +6 -3
- package/dist/types/element/src/binding.d.ts +94 -17
- package/dist/types/element/src/bounds.d.ts +32 -9
- package/dist/types/element/src/bucketFill.d.ts +110 -0
- package/dist/types/element/src/collision.d.ts +21 -5
- package/dist/types/element/src/comparisons.d.ts +8 -5
- package/dist/types/element/src/convertToShape.d.ts +23 -0
- package/dist/types/element/src/cropElement.d.ts +36 -4
- package/dist/types/element/src/delta.d.ts +30 -2
- package/dist/types/element/src/distribute.d.ts +5 -2
- package/dist/types/element/src/dragElements.d.ts +34 -2
- package/dist/types/element/src/duplicate.d.ts +64 -3
- package/dist/types/element/src/elbowArrow.d.ts +7 -0
- package/dist/types/element/src/embeddable.d.ts +3 -2
- package/dist/types/element/src/flowchart.d.ts +9 -11
- package/dist/types/element/src/fractionalIndex.d.ts +2 -2
- package/dist/types/element/src/frame.d.ts +30 -11
- package/dist/types/element/src/groups.d.ts +10 -15
- package/dist/types/element/src/image.d.ts +5 -2
- package/dist/types/element/src/index.d.ts +8 -1
- package/dist/types/element/src/linearElementEditor.d.ts +34 -11
- package/dist/types/element/src/listMarker.d.ts +39 -0
- package/dist/types/element/src/mutateElement.d.ts +3 -1
- package/dist/types/element/src/newElement.d.ts +55 -3
- package/dist/types/element/src/renderElement.d.ts +31 -7
- package/dist/types/element/src/renderEnvironment.d.ts +66 -0
- package/dist/types/element/src/resizeElements.d.ts +14 -4
- package/dist/types/element/src/selection.d.ts +11 -13
- package/dist/types/element/src/shape.d.ts +30 -2
- package/dist/types/element/src/sizeHelpers.d.ts +6 -0
- package/dist/types/element/src/sortElements.d.ts +10 -0
- package/dist/types/element/src/stickyNote.d.ts +191 -0
- package/dist/types/element/src/textElement.d.ts +23 -11
- package/dist/types/element/src/textMeasurements.d.ts +15 -11
- package/dist/types/element/src/textWrapping.d.ts +28 -1
- package/dist/types/element/src/transform.d.ts +31 -8
- package/dist/types/element/src/typeChecks.d.ts +29 -27
- package/dist/types/element/src/types.d.ts +48 -9
- package/dist/types/element/src/utils.d.ts +19 -6
- package/dist/types/element/src/zindex.d.ts +2 -2
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +125 -53
- package/dist/types/excalidraw/actions/actionAlign.d.ts +6 -6
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +86 -213
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +410 -1073
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +84 -36
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +42 -18
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +4 -515
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +182 -0
- package/dist/types/excalidraw/actions/actionDistribute.d.ts +2 -3
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +38 -18
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +85 -37
- package/dist/types/excalidraw/actions/actionExport.d.ts +173 -399
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +1 -0
- package/dist/types/excalidraw/actions/actionFrame.d.ts +151 -684
- package/dist/types/excalidraw/actions/actionGroup.d.ts +100 -52
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +97 -21
- package/dist/types/excalidraw/actions/actionLink.d.ts +43 -19
- package/dist/types/excalidraw/actions/actionMenu.d.ts +38 -18
- package/dist/types/excalidraw/actions/actionProperties.d.ts +120 -56
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +47 -23
- package/dist/types/excalidraw/actions/actionStyles.d.ts +43 -18
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
- package/dist/types/excalidraw/actions/{actionEmbeddable.d.ts → actionToggleArrowBinding.d.ts} +57 -32
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +46 -23
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +195 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +43 -19
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +42 -23
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionToggleShowHints.d.ts +197 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +43 -19
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +44 -20
- package/dist/types/excalidraw/actions/actionToggleWrap.d.ts +12 -0
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +43 -19
- package/dist/types/excalidraw/actions/colorTargets.d.ts +39 -0
- package/dist/types/excalidraw/actions/index.d.ts +6 -2
- package/dist/types/excalidraw/actions/manager.d.ts +1 -0
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +8 -4
- package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
- package/dist/types/excalidraw/appState.d.ts +55 -29
- package/dist/types/excalidraw/charts/charts.bar.d.ts +3 -0
- package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
- package/dist/types/excalidraw/charts/charts.helpers.d.ts +33 -0
- package/dist/types/excalidraw/charts/charts.line.d.ts +3 -0
- package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
- package/dist/types/excalidraw/charts/charts.radar.d.ts +3 -0
- package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
- package/dist/types/excalidraw/charts/index.d.ts +8 -0
- package/dist/types/excalidraw/clipboard.d.ts +4 -7
- package/dist/types/excalidraw/components/Actions.d.ts +17 -12
- package/dist/types/excalidraw/components/ActiveConfirmDialog.d.ts +1 -1
- package/dist/types/excalidraw/components/App.arrowText.d.ts +70 -0
- package/dist/types/excalidraw/components/App.bucketFill.d.ts +48 -0
- package/dist/types/excalidraw/components/App.clipboard.d.ts +31 -0
- package/dist/types/excalidraw/components/App.cursor.d.ts +38 -0
- package/dist/types/excalidraw/components/App.d.ts +372 -116
- package/dist/types/excalidraw/components/App.drawshape.d.ts +55 -0
- package/dist/types/excalidraw/components/App.duplicate.d.ts +101 -0
- package/dist/types/excalidraw/components/App.flowchart.d.ts +21 -0
- package/dist/types/excalidraw/components/App.host.d.ts +102 -0
- package/dist/types/excalidraw/components/App.modifiers.d.ts +38 -0
- package/dist/types/excalidraw/components/App.pan.d.ts +62 -0
- package/dist/types/excalidraw/components/App.selection.d.ts +265 -0
- package/dist/types/excalidraw/components/App.selectionTool.d.ts +93 -0
- package/dist/types/excalidraw/components/App.text.d.ts +146 -0
- package/dist/types/excalidraw/components/App.textTool.d.ts +140 -0
- package/dist/types/excalidraw/components/App.toolDrag.d.ts +63 -0
- package/dist/types/excalidraw/components/App.viewport.d.ts +123 -0
- package/dist/types/excalidraw/components/App.wheel.d.ts +26 -0
- package/dist/types/excalidraw/components/App.wrap.d.ts +31 -0
- package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +9 -3
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +3 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +5 -1
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +9 -2
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +4 -2
- package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +8 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/colorTopPicksDnD.d.ts +11 -0
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +2 -1
- package/dist/types/excalidraw/components/CommandPalette/defaultCommandPaletteItems.d.ts +1 -2
- package/dist/types/excalidraw/components/CommandPalette/types.d.ts +1 -1
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +4 -3
- package/dist/types/excalidraw/components/CursorHint.d.ts +46 -0
- package/dist/types/excalidraw/components/EyeDropper.d.ts +1 -1
- package/dist/types/excalidraw/components/FileDropOverlay.d.ts +2 -0
- package/dist/types/excalidraw/components/FontPicker/FontPicker.d.ts +4 -1
- package/dist/types/excalidraw/components/FontPicker/FontPickerList.d.ts +6 -1
- package/dist/types/excalidraw/components/FontPicker/fontTopPicksDnD.d.ts +12 -0
- package/dist/types/excalidraw/components/IconButton.d.ts +48 -0
- package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
- package/dist/types/excalidraw/components/Island.d.ts +7 -0
- package/dist/types/excalidraw/components/LaserPointerButton.d.ts +2 -4
- package/dist/types/excalidraw/components/LayerUI.d.ts +5 -2
- package/dist/types/excalidraw/components/LibraryMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/LibraryMenuSection.d.ts +6 -2
- package/dist/types/excalidraw/components/LibraryUnit.d.ts +7 -2
- package/dist/types/excalidraw/components/LockButton.d.ts +3 -4
- package/dist/types/excalidraw/components/MagicButton.d.ts +0 -2
- package/dist/types/excalidraw/components/MobileMenu.d.ts +4 -4
- package/dist/types/excalidraw/components/MobileToolbar.d.ts +9 -0
- package/dist/types/excalidraw/components/OverwriteConfirm/OverwriteConfirmState.d.ts +1 -1
- package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
- package/dist/types/excalidraw/components/PenModeButton.d.ts +2 -5
- package/dist/types/excalidraw/components/Popover.d.ts +1 -3
- package/dist/types/excalidraw/components/{ButtonIcon.d.ts → RadioButton.d.ts} +2 -5
- package/dist/types/excalidraw/components/Range.d.ts +10 -4
- package/dist/types/excalidraw/components/SVGLayer.d.ts +1 -1
- package/dist/types/excalidraw/components/SearchMenu.d.ts +1 -1
- package/dist/types/excalidraw/components/Sidebar/Sidebar.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +2 -2
- package/dist/types/excalidraw/components/Stats/Position.d.ts +3 -3
- package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -2
- package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
- package/dist/types/excalidraw/components/TTDDialog/MermaidToExcalidraw.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDContext.d.ts +4 -4
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +8 -2
- package/dist/types/excalidraw/components/TTDDialog/TTDPreviewPanel.d.ts +5 -2
- package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/common.d.ts +4 -1
- package/dist/types/excalidraw/components/TTDDialog/hooks/useTextGeneration.d.ts +3 -2
- package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
- package/dist/types/excalidraw/components/TTDDialog/types.d.ts +14 -1
- package/dist/types/excalidraw/components/TTDDialog/useTTDChatStorage.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +26 -0
- package/dist/types/excalidraw/components/Toast.d.ts +8 -4
- package/dist/types/excalidraw/components/ToolPopover.d.ts +3 -6
- package/dist/types/excalidraw/components/Toolbar.d.ts +11 -0
- package/dist/types/excalidraw/components/Tools.d.ts +151 -0
- package/dist/types/excalidraw/components/Tooltip.d.ts +26 -2
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksContextMenu.d.ts +14 -0
- package/dist/types/excalidraw/components/TopPicksDnD/TopPicksTip.d.ts +11 -0
- package/dist/types/excalidraw/components/TopPicksDnD/topPicksDnD.d.ts +58 -0
- package/dist/types/excalidraw/components/UserList.d.ts +3 -2
- package/dist/types/excalidraw/components/ViewportStatusFrame/ViewportStatusFrame.d.ts +11 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +4 -2
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +3 -0
- package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -1
- package/dist/types/excalidraw/components/footer/Footer.d.ts +3 -1
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +15 -4
- package/dist/types/excalidraw/components/icons.d.ts +27 -10
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +12 -4
- package/dist/types/excalidraw/components/positionElementBesideCursor.d.ts +26 -0
- package/dist/types/excalidraw/components/shapeActionPredicates.d.ts +39 -0
- package/dist/types/excalidraw/data/blob.d.ts +221 -174
- package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
- package/dist/types/excalidraw/data/index.d.ts +9 -10
- package/dist/types/excalidraw/data/json.d.ts +119 -87
- package/dist/types/excalidraw/data/library.d.ts +1 -1
- package/dist/types/excalidraw/data/resave.d.ts +7 -2
- package/dist/types/excalidraw/drawShapeTrail.d.ts +16 -0
- package/dist/types/excalidraw/eraser/index.d.ts +2 -3
- package/dist/types/excalidraw/fonts/Fonts.d.ts +12 -8
- package/dist/types/excalidraw/history.d.ts +10 -4
- package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
- package/dist/types/excalidraw/hooks/useLibraryItemSvg.d.ts +1 -1
- package/dist/types/excalidraw/hooks/useTextEditorFocus.d.ts +5 -5
- package/dist/types/excalidraw/{laser-trails.d.ts → laserTrails.d.ts} +5 -7
- package/dist/types/excalidraw/lasso/index.d.ts +2 -3
- package/dist/types/excalidraw/lasso/utils.d.ts +2 -0
- package/dist/types/excalidraw/mermaid.d.ts +7 -0
- package/dist/types/excalidraw/reactUtils.d.ts +1 -1
- package/dist/types/excalidraw/renderOverrides.d.ts +9 -0
- package/dist/types/excalidraw/renderer/animation.d.ts +15 -4
- package/dist/types/excalidraw/renderer/helpers.d.ts +25 -0
- package/dist/types/excalidraw/renderer/interactiveScene.d.ts +2 -4
- package/dist/types/excalidraw/renderer/staticScene.d.ts +11 -6
- package/dist/types/excalidraw/scene/Renderer.d.ts +490 -21
- package/dist/types/excalidraw/scene/export.d.ts +344 -21
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/types.d.ts +30 -5
- package/dist/types/excalidraw/snapping.d.ts +7 -7
- package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
- package/dist/types/excalidraw/types.d.ts +670 -43
- package/dist/types/excalidraw/viewport.d.ts +302 -0
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +17 -3
- package/dist/types/fractional-indexing/src/index.d.ts +29 -0
- package/dist/types/laser-pointer/src/index.d.ts +2 -0
- package/dist/types/laser-pointer/src/math.d.ts +16 -0
- package/dist/types/laser-pointer/src/simplify.d.ts +2 -0
- package/dist/types/laser-pointer/src/state.d.ts +36 -0
- package/dist/types/math/src/constants.d.ts +0 -1
- package/dist/types/math/src/curve.d.ts +23 -13
- package/dist/types/math/src/index.d.ts +1 -0
- package/dist/types/math/src/pca.d.ts +79 -0
- package/dist/types/math/src/point.d.ts +8 -2
- package/dist/types/math/src/polygon.d.ts +25 -1
- package/dist/types/math/src/segment.d.ts +6 -0
- package/dist/types/math/src/types.d.ts +25 -1
- package/dist/types/utils/src/index.d.ts +4 -3
- package/dist/types/utils/src/shape.d.ts +2 -2
- package/package.json +1 -1
- package/dist/types/excalidraw/animation-frame-handler.d.ts +0 -16
- package/dist/types/excalidraw/charts.d.ts +0 -27
- package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
- package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -15
- package/dist/types/excalidraw/components/FollowMode/FollowMode.d.ts +0 -10
- package/dist/types/excalidraw/components/HandButton.d.ts +0 -10
- package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
- package/dist/types/excalidraw/components/MobileToolBar.d.ts +0 -10
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -8
- package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +0 -24
- package/dist/types/excalidraw/components/ToolButton.d.ts +0 -49
- package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
- package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -11
- package/dist/types/excalidraw/components/shapes.d.ts +0 -190
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
- package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -84
- package/dist/types/excalidraw/cursor.d.ts +0 -5
- package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
- package/dist/types/excalidraw/index.d.ts +0 -47
- package/dist/types/excalidraw/polyfill.d.ts +0 -2
- package/dist/types/excalidraw/scene/scroll.d.ts +0 -18
- package/dist/types/excalidraw/scene/zoom.d.ts +0 -12
- package/dist/types/utils/src/bbox.d.ts +0 -9
- package/dist/types/utils/src/export.d.ts +0 -35
- package/dist/types/utils/src/withinBounds.d.ts +0 -19
package/dist/dev/index.js
CHANGED
|
@@ -1356,6 +1356,8 @@ function validateWCAG2Parms(parms) {
|
|
|
1356
1356
|
import { clamp } from "@excalidraw/math";
|
|
1357
1357
|
import { degreesToRadians } from "@excalidraw/math";
|
|
1358
1358
|
var DARK_MODE_COLORS_CACHE = typeof window !== "undefined" ? /* @__PURE__ */ new Map() : null;
|
|
1359
|
+
var DARK_MODE_FILTER_INVERT_PERCENT = 93;
|
|
1360
|
+
var DARK_MODE_FILTER_HUE_ROTATE_DEGREES = 180;
|
|
1359
1361
|
function cssHueRotate(red, green, blue, degrees) {
|
|
1360
1362
|
const r = red / 255;
|
|
1361
1363
|
const g = green / 255;
|
|
@@ -1394,7 +1396,10 @@ var cssInvert = (r, g, b, percent) => {
|
|
|
1394
1396
|
const invertedB = invertComponent(b);
|
|
1395
1397
|
return { r: invertedR, g: invertedG, b: invertedB };
|
|
1396
1398
|
};
|
|
1397
|
-
var applyDarkModeFilter = (color) => {
|
|
1399
|
+
var applyDarkModeFilter = (color, enable = true) => {
|
|
1400
|
+
if (!enable) {
|
|
1401
|
+
return color;
|
|
1402
|
+
}
|
|
1398
1403
|
const cached = DARK_MODE_COLORS_CACHE?.get(color);
|
|
1399
1404
|
if (cached) {
|
|
1400
1405
|
return cached;
|
|
@@ -1402,12 +1407,17 @@ var applyDarkModeFilter = (color) => {
|
|
|
1402
1407
|
const tc = tinycolor(color);
|
|
1403
1408
|
const alpha = tc.getAlpha();
|
|
1404
1409
|
const rgb = tc.toRgb();
|
|
1405
|
-
const inverted = cssInvert(
|
|
1410
|
+
const inverted = cssInvert(
|
|
1411
|
+
rgb.r,
|
|
1412
|
+
rgb.g,
|
|
1413
|
+
rgb.b,
|
|
1414
|
+
DARK_MODE_FILTER_INVERT_PERCENT
|
|
1415
|
+
);
|
|
1406
1416
|
const rotated = cssHueRotate(
|
|
1407
1417
|
inverted.r,
|
|
1408
1418
|
inverted.g,
|
|
1409
1419
|
inverted.b,
|
|
1410
|
-
|
|
1420
|
+
DARK_MODE_FILTER_HUE_ROTATE_DEGREES
|
|
1411
1421
|
);
|
|
1412
1422
|
const result = rgbToHex2(rotated.r, rotated.g, rotated.b, alpha);
|
|
1413
1423
|
if (DARK_MODE_COLORS_CACHE) {
|
|
@@ -1415,6 +1425,33 @@ var applyDarkModeFilter = (color) => {
|
|
|
1415
1425
|
}
|
|
1416
1426
|
return result;
|
|
1417
1427
|
};
|
|
1428
|
+
var _reverseDarkModeInvert = (r, g, b) => {
|
|
1429
|
+
const p = DARK_MODE_FILTER_INVERT_PERCENT / 100;
|
|
1430
|
+
const denominator = 1 - 2 * p;
|
|
1431
|
+
const restore = (color) => Math.round(clamp((color - 255 * p) / denominator, 0, 255));
|
|
1432
|
+
return {
|
|
1433
|
+
r: restore(r),
|
|
1434
|
+
g: restore(g),
|
|
1435
|
+
b: restore(b)
|
|
1436
|
+
};
|
|
1437
|
+
};
|
|
1438
|
+
var removeDarkModeFilter = (color) => {
|
|
1439
|
+
const tc = tinycolor(color);
|
|
1440
|
+
const alpha = tc.getAlpha();
|
|
1441
|
+
const rgb = tc.toRgb();
|
|
1442
|
+
const rotatedBack = cssHueRotate(
|
|
1443
|
+
rgb.r,
|
|
1444
|
+
rgb.g,
|
|
1445
|
+
rgb.b,
|
|
1446
|
+
DARK_MODE_FILTER_HUE_ROTATE_DEGREES
|
|
1447
|
+
);
|
|
1448
|
+
const restored = _reverseDarkModeInvert(
|
|
1449
|
+
rotatedBack.r,
|
|
1450
|
+
rotatedBack.g,
|
|
1451
|
+
rotatedBack.b
|
|
1452
|
+
);
|
|
1453
|
+
return rgbToHex2(restored.r, restored.g, restored.b, alpha);
|
|
1454
|
+
};
|
|
1418
1455
|
var pick = (source, keys) => {
|
|
1419
1456
|
return keys.reduce((acc, key) => {
|
|
1420
1457
|
if (key in source) {
|
|
@@ -1460,6 +1497,7 @@ var COMMON_ELEMENT_SHADES = pick(COLOR_PALETTE, [
|
|
|
1460
1497
|
"orange",
|
|
1461
1498
|
"red"
|
|
1462
1499
|
]);
|
|
1500
|
+
var COLOR_TOP_PICKS_SLOTS = 5;
|
|
1463
1501
|
var DEFAULT_ELEMENT_STROKE_PICKS = [
|
|
1464
1502
|
COLOR_PALETTE.black,
|
|
1465
1503
|
COLOR_PALETTE.red[DEFAULT_ELEMENT_STROKE_COLOR_INDEX],
|
|
@@ -1474,6 +1512,22 @@ var DEFAULT_ELEMENT_BACKGROUND_PICKS = [
|
|
|
1474
1512
|
COLOR_PALETTE.blue[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX],
|
|
1475
1513
|
COLOR_PALETTE.yellow[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX]
|
|
1476
1514
|
];
|
|
1515
|
+
var BUCKET_FILL_BACKGROUND_PICKS = [
|
|
1516
|
+
COLOR_PALETTE.white,
|
|
1517
|
+
COLOR_PALETTE.red[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX],
|
|
1518
|
+
COLOR_PALETTE.green[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX],
|
|
1519
|
+
COLOR_PALETTE.blue[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX],
|
|
1520
|
+
COLOR_PALETTE.yellow[DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX]
|
|
1521
|
+
];
|
|
1522
|
+
var DEFAULT_STICKY_NOTE_BG = "#ffdf6b";
|
|
1523
|
+
var STICKY_NOTE_STROKE_PICKS = DEFAULT_ELEMENT_STROKE_PICKS;
|
|
1524
|
+
var STICKY_NOTE_BACKGROUND_PICKS = [
|
|
1525
|
+
DEFAULT_STICKY_NOTE_BG,
|
|
1526
|
+
COLOR_PALETTE.pink[1],
|
|
1527
|
+
COLOR_PALETTE.green[1],
|
|
1528
|
+
COLOR_PALETTE.blue[1],
|
|
1529
|
+
COLOR_PALETTE.orange[1]
|
|
1530
|
+
];
|
|
1477
1531
|
var DEFAULT_CANVAS_BACKGROUND_PICKS = [
|
|
1478
1532
|
COLOR_PALETTE.white,
|
|
1479
1533
|
// radix slate2
|
|
@@ -1525,6 +1579,14 @@ var rgbToHex2 = (r, g, b, a) => {
|
|
|
1525
1579
|
}
|
|
1526
1580
|
return hex6;
|
|
1527
1581
|
};
|
|
1582
|
+
var setColorAlpha = (color, alpha) => {
|
|
1583
|
+
const tc = tinycolor(color);
|
|
1584
|
+
if (!tc.isValid()) {
|
|
1585
|
+
return color;
|
|
1586
|
+
}
|
|
1587
|
+
const { r, g, b } = tc.toRgb();
|
|
1588
|
+
return rgbToHex2(r, g, b, alpha);
|
|
1589
|
+
};
|
|
1528
1590
|
var colorToHex = (color) => {
|
|
1529
1591
|
const tc = tinycolor(color);
|
|
1530
1592
|
if (!tc.isValid()) {
|
|
@@ -1536,6 +1598,9 @@ var colorToHex = (color) => {
|
|
|
1536
1598
|
var isTransparent = (color) => {
|
|
1537
1599
|
return tinycolor(color).getAlpha() === 0;
|
|
1538
1600
|
};
|
|
1601
|
+
var isOpaqueColor = (color) => {
|
|
1602
|
+
return tinycolor(color).getAlpha() === 1;
|
|
1603
|
+
};
|
|
1539
1604
|
var COLOR_OUTLINE_CONTRAST_THRESHOLD = 240;
|
|
1540
1605
|
var calculateContrast = (r, g, b) => {
|
|
1541
1606
|
const yiq = (r * 299 + g * 587 + b * 114) / 1e3;
|
|
@@ -1562,7 +1627,7 @@ var normalizeInputColor = (color) => {
|
|
|
1562
1627
|
}
|
|
1563
1628
|
const tc = tinycolor(color);
|
|
1564
1629
|
if (tc.isValid()) {
|
|
1565
|
-
if (tc.getFormat()
|
|
1630
|
+
if (["hex", "hex8"].includes(tc.getFormat()) && !color.startsWith("#")) {
|
|
1566
1631
|
return `#${color}`;
|
|
1567
1632
|
}
|
|
1568
1633
|
return color;
|
|
@@ -1575,6 +1640,8 @@ init_define_import_meta_env();
|
|
|
1575
1640
|
var supportsResizeObserver = typeof window !== "undefined" && "ResizeObserver" in window;
|
|
1576
1641
|
var APP_NAME = "Excalidraw";
|
|
1577
1642
|
var TEXT_AUTOWRAP_THRESHOLD = 36;
|
|
1643
|
+
var TEXT_VIEWPORT_PADDING = 20;
|
|
1644
|
+
var TEXT_MAX_WRAP_WIDTH = 800;
|
|
1578
1645
|
var DRAGGING_THRESHOLD = 10;
|
|
1579
1646
|
var MINIMUM_ARROW_SIZE = 20;
|
|
1580
1647
|
var LINE_CONFIRM_THRESHOLD = 8;
|
|
@@ -1626,6 +1693,7 @@ var EVENT = /* @__PURE__ */ ((EVENT2) => {
|
|
|
1626
1693
|
EVENT2["POINTER_MOVE"] = "pointermove";
|
|
1627
1694
|
EVENT2["POINTER_DOWN"] = "pointerdown";
|
|
1628
1695
|
EVENT2["POINTER_UP"] = "pointerup";
|
|
1696
|
+
EVENT2["POINTER_CANCEL"] = "pointercancel";
|
|
1629
1697
|
EVENT2["STATE_CHANGE"] = "statechange";
|
|
1630
1698
|
EVENT2["WHEEL"] = "wheel";
|
|
1631
1699
|
EVENT2["TOUCH_START"] = "touchstart";
|
|
@@ -1737,7 +1805,28 @@ var FRAME_STYLE = {
|
|
|
1737
1805
|
};
|
|
1738
1806
|
var MIN_FONT_SIZE = 1;
|
|
1739
1807
|
var DEFAULT_FONT_SIZE = 20;
|
|
1808
|
+
var STICKY_NOTE_MIN_FONT_SIZE = 16;
|
|
1809
|
+
var STICKY_NOTE_MAX_FONT_SIZE = 512;
|
|
1810
|
+
var STICKY_NOTE_FALLBACK_FONT_SIZE = 28;
|
|
1811
|
+
var STICKY_NOTE_FONT_STEP = 2;
|
|
1812
|
+
var STICKY_NOTE_PADDING = 16;
|
|
1813
|
+
var STICKY_NOTE_FOOTER = {
|
|
1814
|
+
height: 20,
|
|
1815
|
+
fontSize: 12,
|
|
1816
|
+
fontFamily: "Helvetica, Arial, sans-serif",
|
|
1817
|
+
baselineFromBottom: 14,
|
|
1818
|
+
opacity: 1,
|
|
1819
|
+
minBodyWidthForYear: 80
|
|
1820
|
+
};
|
|
1821
|
+
var STICKY_NOTE_BODY_INSET_Y = STICKY_NOTE_PADDING * 2 + STICKY_NOTE_FOOTER.height;
|
|
1822
|
+
var DEFAULT_STICKY_NOTE_SIZE = 250;
|
|
1823
|
+
var STICKY_NOTE_MIN_SIZE = 75;
|
|
1824
|
+
var STICKY_NOTE_SHADOW_OFFSET = 3;
|
|
1825
|
+
var STICKY_NOTE_SHADOW_OPACITY = 0.16;
|
|
1826
|
+
var STICKY_NOTE_EDGE_SHADOW_WIDTH = 0.5;
|
|
1827
|
+
var STICKY_NOTE_EDGE_SHADOW_OPACITY = 0.08;
|
|
1740
1828
|
var DEFAULT_FONT_FAMILY = FONT_FAMILY.Excalifont;
|
|
1829
|
+
var FONT_TOP_PICKS_SLOTS = 3;
|
|
1741
1830
|
var DEFAULT_TEXT_ALIGN = "left";
|
|
1742
1831
|
var DEFAULT_VERTICAL_ALIGN = "top";
|
|
1743
1832
|
var DEFAULT_VERSION = "{version}";
|
|
@@ -1807,9 +1896,13 @@ var TOUCH_CTX_MENU_TIMEOUT = 500;
|
|
|
1807
1896
|
var TITLE_TIMEOUT = 1e4;
|
|
1808
1897
|
var VERSION_TIMEOUT = 3e4;
|
|
1809
1898
|
var SCROLL_TIMEOUT = 100;
|
|
1899
|
+
var ZEN_MODE_TRANSITION_DURATION = 250;
|
|
1810
1900
|
var ZOOM_STEP = 0.1;
|
|
1811
1901
|
var MIN_ZOOM = 0.1;
|
|
1812
1902
|
var MAX_ZOOM = 30;
|
|
1903
|
+
var DEFAULT_ZOOM = Object.freeze({
|
|
1904
|
+
value: 1
|
|
1905
|
+
});
|
|
1813
1906
|
var HYPERLINK_TOOLTIP_DELAY = 300;
|
|
1814
1907
|
var IDLE_THRESHOLD = 6e4;
|
|
1815
1908
|
var ACTIVE_THRESHOLD = 3e3;
|
|
@@ -1836,8 +1929,10 @@ var DEFAULT_UI_OPTIONS = {
|
|
|
1836
1929
|
var MAX_DECIMALS_FOR_SVG_EXPORT = 2;
|
|
1837
1930
|
var EXPORT_SCALES = [1, 2, 3];
|
|
1838
1931
|
var DEFAULT_EXPORT_PADDING = 10;
|
|
1839
|
-
var
|
|
1840
|
-
|
|
1932
|
+
var DEFAULT_IMAGE_OPTIONS = {
|
|
1933
|
+
maxWidthOrHeight: 1440,
|
|
1934
|
+
maxFileSizeBytes: 4 * 1024 * 1024
|
|
1935
|
+
};
|
|
1841
1936
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
1842
1937
|
var SVG_DOCUMENT_PREAMBLE = `<?xml version="1.0" standalone="no"?>
|
|
1843
1938
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
@@ -1861,6 +1956,7 @@ var TEXT_ALIGN = {
|
|
|
1861
1956
|
RIGHT: "right"
|
|
1862
1957
|
};
|
|
1863
1958
|
var ELEMENT_READY_TO_ERASE_OPACITY = 20;
|
|
1959
|
+
var ELEMENT_PENDING_DRAW_SHAPE_OPACITY = 70;
|
|
1864
1960
|
var DEFAULT_PROPORTIONAL_RADIUS = 0.25;
|
|
1865
1961
|
var DEFAULT_ADAPTIVE_RADIUS = 32;
|
|
1866
1962
|
var ROUNDNESS = {
|
|
@@ -1884,16 +1980,34 @@ var ROUGHNESS = {
|
|
|
1884
1980
|
artist: 1,
|
|
1885
1981
|
cartoonist: 2
|
|
1886
1982
|
};
|
|
1983
|
+
var STROKE_WIDTH_KEYS = [
|
|
1984
|
+
"thin",
|
|
1985
|
+
"medium",
|
|
1986
|
+
"bold"
|
|
1987
|
+
];
|
|
1887
1988
|
var STROKE_WIDTH = {
|
|
1888
1989
|
thin: 1,
|
|
1990
|
+
medium: 2,
|
|
1991
|
+
bold: 4,
|
|
1992
|
+
extraBold: 8
|
|
1993
|
+
// unused (may be introduced in the future)
|
|
1994
|
+
};
|
|
1995
|
+
var FREEDRAW_STROKE_WIDTH = {
|
|
1996
|
+
thin: 0.5,
|
|
1997
|
+
medium: 1,
|
|
1889
1998
|
bold: 2,
|
|
1890
1999
|
extraBold: 4
|
|
2000
|
+
// legacy (may be used again in the future)
|
|
2001
|
+
};
|
|
2002
|
+
var getStrokeWidthByKey = (elementType, strokeWidthKey) => {
|
|
2003
|
+
return elementType === "freedraw" ? FREEDRAW_STROKE_WIDTH[strokeWidthKey] : STROKE_WIDTH[strokeWidthKey];
|
|
1891
2004
|
};
|
|
2005
|
+
var DEFAULT_ELEMENT_STROKE_WIDTH_KEY = "medium";
|
|
1892
2006
|
var DEFAULT_ELEMENT_PROPS = {
|
|
1893
2007
|
strokeColor: COLOR_PALETTE.black,
|
|
1894
2008
|
backgroundColor: COLOR_PALETTE.transparent,
|
|
1895
2009
|
fillStyle: "solid",
|
|
1896
|
-
strokeWidth:
|
|
2010
|
+
strokeWidth: STROKE_WIDTH[DEFAULT_ELEMENT_STROKE_WIDTH_KEY],
|
|
1897
2011
|
strokeStyle: "solid",
|
|
1898
2012
|
roughness: ROUGHNESS.artist,
|
|
1899
2013
|
opacity: 100,
|
|
@@ -1925,8 +2039,11 @@ var TOOL_TYPE = {
|
|
|
1925
2039
|
hand: "hand",
|
|
1926
2040
|
frame: "frame",
|
|
1927
2041
|
magicframe: "magicframe",
|
|
2042
|
+
stickynote: "stickynote",
|
|
1928
2043
|
embeddable: "embeddable",
|
|
1929
|
-
laser: "laser"
|
|
2044
|
+
laser: "laser",
|
|
2045
|
+
autoshape: "autoshape",
|
|
2046
|
+
bucketfill: "bucketfill"
|
|
1930
2047
|
};
|
|
1931
2048
|
var EDITOR_LS_KEYS = {
|
|
1932
2049
|
OAI_API_KEY: "excalidraw-oai-api-key",
|
|
@@ -1957,6 +2074,8 @@ var BIND_MODE_TIMEOUT = 700;
|
|
|
1957
2074
|
var MOBILE_ACTION_BUTTON_BG = {
|
|
1958
2075
|
background: "var(--mobile-action-button-bg)"
|
|
1959
2076
|
};
|
|
2077
|
+
var DEFAULT_STROKE_STREAMLINE = 0.5;
|
|
2078
|
+
var DEFAULT_STROKE_STREAMLINE_PRECISE = 0.2;
|
|
1960
2079
|
|
|
1961
2080
|
// src/font-metadata.ts
|
|
1962
2081
|
init_define_import_meta_env();
|
|
@@ -2123,15 +2242,18 @@ var MQ_MIN_TABLET = MQ_MAX_MOBILE + 1;
|
|
|
2123
2242
|
var MQ_MAX_TABLET = 1180;
|
|
2124
2243
|
var MQ_MIN_WIDTH_DESKTOP = 1440;
|
|
2125
2244
|
var MQ_RIGHT_SIDEBAR_MIN_WIDTH = 1229;
|
|
2126
|
-
var
|
|
2127
|
-
var
|
|
2128
|
-
var
|
|
2129
|
-
var
|
|
2130
|
-
var
|
|
2131
|
-
var
|
|
2132
|
-
var
|
|
2133
|
-
|
|
2134
|
-
var
|
|
2245
|
+
var ua = typeof navigator === "undefined" ? void 0 : navigator;
|
|
2246
|
+
var uaPlatform = ua?.platform ?? "";
|
|
2247
|
+
var uaString = ua?.userAgent ?? "";
|
|
2248
|
+
var isDarwin = /Mac|iPod|iPhone|iPad/.test(uaPlatform);
|
|
2249
|
+
var isWindows = /^Win/.test(uaPlatform);
|
|
2250
|
+
var isAndroid = /\b(android)\b/i.test(uaString);
|
|
2251
|
+
var isFirefox = typeof window !== "undefined" && "netscape" in window && uaString.indexOf("rv:") > 1 && uaString.indexOf("Gecko") > 1;
|
|
2252
|
+
var isChrome = uaString.indexOf("Chrome") !== -1;
|
|
2253
|
+
var isSafari = !isChrome && uaString.indexOf("Safari") !== -1;
|
|
2254
|
+
var isIOS = /iPad|iPhone/i.test(uaPlatform) || // iPadOS 13+
|
|
2255
|
+
uaString.includes("Mac") && typeof document !== "undefined" && "ontouchend" in document;
|
|
2256
|
+
var isBrave = () => ua?.brave?.isBrave?.name === "isBrave";
|
|
2135
2257
|
var isMobileBreakpoint = (width, height) => {
|
|
2136
2258
|
return width <= MQ_MAX_MOBILE || height < MQ_MAX_HEIGHT_LANDSCAPE && width < MQ_MAX_WIDTH_LANDSCAPE;
|
|
2137
2259
|
};
|
|
@@ -2141,7 +2263,7 @@ var isTabletBreakpoint = (editorWidth, editorHeight) => {
|
|
|
2141
2263
|
return minSide >= MQ_MIN_TABLET && maxSide <= MQ_MAX_TABLET;
|
|
2142
2264
|
};
|
|
2143
2265
|
var isMobileOrTablet = () => {
|
|
2144
|
-
const
|
|
2266
|
+
const ua2 = navigator.userAgent || "";
|
|
2145
2267
|
const platform = navigator.platform || "";
|
|
2146
2268
|
const uaData = navigator.userAgentData;
|
|
2147
2269
|
if (uaData) {
|
|
@@ -2162,14 +2284,14 @@ var isMobileOrTablet = () => {
|
|
|
2162
2284
|
return true;
|
|
2163
2285
|
}
|
|
2164
2286
|
if (isAndroid) {
|
|
2165
|
-
const isAndroidPhone = /Mobile/i.test(
|
|
2287
|
+
const isAndroidPhone = /Mobile/i.test(ua2);
|
|
2166
2288
|
const isAndroidTablet = !isAndroidPhone;
|
|
2167
2289
|
if (isAndroidPhone || isAndroidTablet) {
|
|
2168
2290
|
const looksTouchTablet = matchMedia?.("(hover: none)").matches && matchMedia?.("(pointer: coarse)").matches;
|
|
2169
2291
|
return looksTouchTablet;
|
|
2170
2292
|
}
|
|
2171
2293
|
}
|
|
2172
|
-
const looksDesktopPlatform = /Win|Linux|CrOS|Mac/.test(platform) || /Windows NT|X11|CrOS|Macintosh/.test(
|
|
2294
|
+
const looksDesktopPlatform = /Win|Linux|CrOS|Mac/.test(platform) || /Windows NT|X11|CrOS|Macintosh/.test(ua2);
|
|
2173
2295
|
if (looksDesktopPlatform) {
|
|
2174
2296
|
return false;
|
|
2175
2297
|
}
|
|
@@ -2286,6 +2408,7 @@ var KEYS = {
|
|
|
2286
2408
|
SUBTRACT: "-",
|
|
2287
2409
|
SLASH: "/",
|
|
2288
2410
|
A: "a",
|
|
2411
|
+
B: "b",
|
|
2289
2412
|
C: "c",
|
|
2290
2413
|
D: "d",
|
|
2291
2414
|
E: "e",
|
|
@@ -2294,6 +2417,7 @@ var KEYS = {
|
|
|
2294
2417
|
H: "h",
|
|
2295
2418
|
I: "i",
|
|
2296
2419
|
L: "l",
|
|
2420
|
+
N: "n",
|
|
2297
2421
|
O: "o",
|
|
2298
2422
|
P: "p",
|
|
2299
2423
|
Q: "q",
|
|
@@ -2337,6 +2461,7 @@ var shouldRotateWithDiscreteAngle = (event) => event.shiftKey;
|
|
|
2337
2461
|
// src/points.ts
|
|
2338
2462
|
init_define_import_meta_env();
|
|
2339
2463
|
import {
|
|
2464
|
+
pointFrom,
|
|
2340
2465
|
pointFromPair
|
|
2341
2466
|
} from "@excalidraw/math";
|
|
2342
2467
|
var getSizeFromPoints = (points) => {
|
|
@@ -2381,12 +2506,12 @@ var rescalePoints = (dimension, newSize, points, normalize) => {
|
|
|
2381
2506
|
};
|
|
2382
2507
|
var getGridPoint = (x, y, gridSize) => {
|
|
2383
2508
|
if (gridSize) {
|
|
2384
|
-
return
|
|
2509
|
+
return pointFrom(
|
|
2385
2510
|
Math.round(x / gridSize) * gridSize,
|
|
2386
2511
|
Math.round(y / gridSize) * gridSize
|
|
2387
|
-
|
|
2512
|
+
);
|
|
2388
2513
|
}
|
|
2389
|
-
return
|
|
2514
|
+
return pointFrom(x, y);
|
|
2390
2515
|
};
|
|
2391
2516
|
|
|
2392
2517
|
// src/promise-pool.ts
|
|
@@ -2477,14 +2602,28 @@ var getDateTime = () => {
|
|
|
2477
2602
|
return `${year}-${month}-${day}-${hr}${min}`;
|
|
2478
2603
|
};
|
|
2479
2604
|
var capitalizeString = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
2480
|
-
var
|
|
2481
|
-
|
|
2482
|
-
|
|
2605
|
+
var getTargetWindow = (target) => {
|
|
2606
|
+
const owner = target;
|
|
2607
|
+
return owner?.ownerDocument?.defaultView ?? owner?.defaultView ?? (typeof window === "undefined" ? null : window);
|
|
2608
|
+
};
|
|
2609
|
+
var isToolIcon = (target) => {
|
|
2610
|
+
const targetWindow = getTargetWindow(target);
|
|
2611
|
+
return !!targetWindow && target instanceof targetWindow.HTMLElement && target.className.includes("ToolIcon");
|
|
2612
|
+
};
|
|
2613
|
+
var isInputLike = (target) => {
|
|
2614
|
+
const targetWindow = getTargetWindow(target);
|
|
2615
|
+
return !!targetWindow && (target instanceof targetWindow.HTMLElement && target.dataset.type === "wysiwyg" || target instanceof targetWindow.HTMLBRElement || // newline in wysiwyg
|
|
2616
|
+
target instanceof targetWindow.HTMLInputElement || target instanceof targetWindow.HTMLTextAreaElement || target instanceof targetWindow.HTMLSelectElement);
|
|
2617
|
+
};
|
|
2483
2618
|
var isInteractive = (target) => {
|
|
2484
|
-
|
|
2619
|
+
const targetWindow = getTargetWindow(target);
|
|
2620
|
+
return isInputLike(target) || !!targetWindow && target instanceof targetWindow.Element && !!target.closest("label, button");
|
|
2621
|
+
};
|
|
2622
|
+
var isWritableElement = (target) => {
|
|
2623
|
+
const targetWindow = getTargetWindow(target);
|
|
2624
|
+
return !!targetWindow && (target instanceof targetWindow.HTMLElement && target.dataset.type === "wysiwyg" || target instanceof targetWindow.HTMLBRElement || // newline in wysiwyg
|
|
2625
|
+
target instanceof targetWindow.HTMLTextAreaElement || target instanceof targetWindow.HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password" || target.type === "search") || target instanceof targetWindow.HTMLElement && target.closest(".cm-editor") !== null);
|
|
2485
2626
|
};
|
|
2486
|
-
var isWritableElement = (target) => target instanceof HTMLElement && target.dataset.type === "wysiwyg" || target instanceof HTMLBRElement || // newline in wysiwyg
|
|
2487
|
-
target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password" || target.type === "search");
|
|
2488
2627
|
var getFontFamilyString = ({
|
|
2489
2628
|
fontFamily
|
|
2490
2629
|
}) => {
|
|
@@ -2529,48 +2668,40 @@ var debounce = (fn, timeout) => {
|
|
|
2529
2668
|
};
|
|
2530
2669
|
return ret;
|
|
2531
2670
|
};
|
|
2532
|
-
var throttleRAF = (fn,
|
|
2671
|
+
var throttleRAF = (fn, ownerWindow) => {
|
|
2533
2672
|
let timerId = null;
|
|
2534
2673
|
let lastArgs = null;
|
|
2535
|
-
|
|
2536
|
-
const scheduleFunc = (
|
|
2537
|
-
timerId =
|
|
2674
|
+
const getOwnerWindow = () => ownerWindow ?? window;
|
|
2675
|
+
const scheduleFunc = () => {
|
|
2676
|
+
timerId = getOwnerWindow().requestAnimationFrame(() => {
|
|
2538
2677
|
timerId = null;
|
|
2539
|
-
|
|
2678
|
+
const args = lastArgs;
|
|
2540
2679
|
lastArgs = null;
|
|
2541
|
-
if (
|
|
2542
|
-
|
|
2543
|
-
lastArgsTrailing = null;
|
|
2544
|
-
scheduleFunc(lastArgs);
|
|
2680
|
+
if (args) {
|
|
2681
|
+
fn(...args);
|
|
2545
2682
|
}
|
|
2546
2683
|
});
|
|
2547
2684
|
};
|
|
2548
2685
|
const ret = (...args) => {
|
|
2549
|
-
if (isTestEnv()) {
|
|
2550
|
-
fn(...args);
|
|
2551
|
-
return;
|
|
2552
|
-
}
|
|
2553
2686
|
lastArgs = args;
|
|
2554
2687
|
if (timerId === null) {
|
|
2555
|
-
scheduleFunc(
|
|
2556
|
-
} else if (opts?.trailing) {
|
|
2557
|
-
lastArgsTrailing = args;
|
|
2688
|
+
scheduleFunc();
|
|
2558
2689
|
}
|
|
2559
2690
|
};
|
|
2560
2691
|
ret.flush = () => {
|
|
2561
2692
|
if (timerId !== null) {
|
|
2562
|
-
cancelAnimationFrame(timerId);
|
|
2693
|
+
getOwnerWindow().cancelAnimationFrame(timerId);
|
|
2563
2694
|
timerId = null;
|
|
2564
2695
|
}
|
|
2565
2696
|
if (lastArgs) {
|
|
2566
|
-
fn(...
|
|
2567
|
-
lastArgs =
|
|
2697
|
+
fn(...lastArgs);
|
|
2698
|
+
lastArgs = null;
|
|
2568
2699
|
}
|
|
2569
2700
|
};
|
|
2570
2701
|
ret.cancel = () => {
|
|
2571
|
-
lastArgs =
|
|
2702
|
+
lastArgs = null;
|
|
2572
2703
|
if (timerId !== null) {
|
|
2573
|
-
cancelAnimationFrame(timerId);
|
|
2704
|
+
getOwnerWindow().cancelAnimationFrame(timerId);
|
|
2574
2705
|
timerId = null;
|
|
2575
2706
|
}
|
|
2576
2707
|
};
|
|
@@ -2579,67 +2710,6 @@ var throttleRAF = (fn, opts) => {
|
|
|
2579
2710
|
var easeOut = (k) => {
|
|
2580
2711
|
return 1 - Math.pow(1 - k, 4);
|
|
2581
2712
|
};
|
|
2582
|
-
var easeOutInterpolate = (from, to, progress) => {
|
|
2583
|
-
return (to - from) * easeOut(progress) + from;
|
|
2584
|
-
};
|
|
2585
|
-
var easeToValuesRAF = ({
|
|
2586
|
-
fromValues,
|
|
2587
|
-
toValues,
|
|
2588
|
-
onStep,
|
|
2589
|
-
duration = 250,
|
|
2590
|
-
interpolateValue,
|
|
2591
|
-
onStart,
|
|
2592
|
-
onEnd,
|
|
2593
|
-
onCancel
|
|
2594
|
-
}) => {
|
|
2595
|
-
let canceled = false;
|
|
2596
|
-
let frameId = 0;
|
|
2597
|
-
let startTime;
|
|
2598
|
-
function step(timestamp) {
|
|
2599
|
-
if (canceled) {
|
|
2600
|
-
return;
|
|
2601
|
-
}
|
|
2602
|
-
if (startTime === void 0) {
|
|
2603
|
-
startTime = timestamp;
|
|
2604
|
-
onStart?.();
|
|
2605
|
-
}
|
|
2606
|
-
const elapsed = Math.min(timestamp - startTime, duration);
|
|
2607
|
-
const factor = easeOut(elapsed / duration);
|
|
2608
|
-
const newValues = {};
|
|
2609
|
-
Object.keys(fromValues).forEach((key) => {
|
|
2610
|
-
const _key = key;
|
|
2611
|
-
const result = (toValues[_key] - fromValues[_key]) * factor + fromValues[_key];
|
|
2612
|
-
newValues[_key] = result;
|
|
2613
|
-
});
|
|
2614
|
-
onStep(newValues);
|
|
2615
|
-
if (elapsed < duration) {
|
|
2616
|
-
const progress = elapsed / duration;
|
|
2617
|
-
const newValues2 = {};
|
|
2618
|
-
Object.keys(fromValues).forEach((key) => {
|
|
2619
|
-
const _key = key;
|
|
2620
|
-
const startValue = fromValues[_key];
|
|
2621
|
-
const endValue = toValues[_key];
|
|
2622
|
-
let result;
|
|
2623
|
-
result = interpolateValue ? interpolateValue(startValue, endValue, progress, _key) : easeOutInterpolate(startValue, endValue, progress);
|
|
2624
|
-
if (result == null) {
|
|
2625
|
-
result = easeOutInterpolate(startValue, endValue, progress);
|
|
2626
|
-
}
|
|
2627
|
-
newValues2[_key] = result;
|
|
2628
|
-
});
|
|
2629
|
-
onStep(newValues2);
|
|
2630
|
-
frameId = window.requestAnimationFrame(step);
|
|
2631
|
-
} else {
|
|
2632
|
-
onStep(toValues);
|
|
2633
|
-
onEnd?.();
|
|
2634
|
-
}
|
|
2635
|
-
}
|
|
2636
|
-
frameId = window.requestAnimationFrame(step);
|
|
2637
|
-
return () => {
|
|
2638
|
-
onCancel?.();
|
|
2639
|
-
canceled = true;
|
|
2640
|
-
window.cancelAnimationFrame(frameId);
|
|
2641
|
-
};
|
|
2642
|
-
};
|
|
2643
2713
|
var chunk = (array, size) => {
|
|
2644
2714
|
if (!array.length || size < 1) {
|
|
2645
2715
|
return [];
|
|
@@ -2682,7 +2752,7 @@ var updateActiveTool = (appState, data) => {
|
|
|
2682
2752
|
}
|
|
2683
2753
|
return {
|
|
2684
2754
|
...appState.activeTool,
|
|
2685
|
-
lastActiveTool: data.
|
|
2755
|
+
lastActiveTool: data.lastActiveTool === void 0 ? appState.activeTool.lastActiveTool : data.lastActiveTool,
|
|
2686
2756
|
type: data.type,
|
|
2687
2757
|
customType: null,
|
|
2688
2758
|
locked: data.locked ?? appState.activeTool.locked,
|
|
@@ -2719,6 +2789,8 @@ var RS_LTR_CHARS = "A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FF
|
|
|
2719
2789
|
var RS_RTL_CHARS = "\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC";
|
|
2720
2790
|
var RE_RTL_CHECK = new RegExp(`^[^${RS_LTR_CHARS}]*[${RS_RTL_CHARS}]`);
|
|
2721
2791
|
var isRTL = (text) => RE_RTL_CHECK.test(text);
|
|
2792
|
+
var RE_RTL_CHARS = new RegExp(`[${RS_RTL_CHARS}]`);
|
|
2793
|
+
var hasRTLChars = (text) => RE_RTL_CHARS.test(text);
|
|
2722
2794
|
var tupleToCoors = (xyTuple) => {
|
|
2723
2795
|
const [x, y] = xyTuple;
|
|
2724
2796
|
return { x, y };
|
|
@@ -2809,19 +2881,21 @@ var supportsEmoji = () => {
|
|
|
2809
2881
|
return ctx.getImageData(offset, offset, 1, 1).data[0] !== 0;
|
|
2810
2882
|
};
|
|
2811
2883
|
var getNearestScrollableContainer = (element) => {
|
|
2884
|
+
const ownerDocument = element.ownerDocument;
|
|
2885
|
+
const ownerWindow = ownerDocument.defaultView ?? window;
|
|
2812
2886
|
let parent = element.parentElement;
|
|
2813
2887
|
while (parent) {
|
|
2814
|
-
if (parent ===
|
|
2815
|
-
return
|
|
2888
|
+
if (parent === ownerDocument.body) {
|
|
2889
|
+
return ownerDocument;
|
|
2816
2890
|
}
|
|
2817
|
-
const { overflowY } =
|
|
2891
|
+
const { overflowY } = ownerWindow.getComputedStyle(parent);
|
|
2818
2892
|
const hasScrollableContent = parent.scrollHeight > parent.clientHeight;
|
|
2819
2893
|
if (hasScrollableContent && (overflowY === "auto" || overflowY === "scroll" || overflowY === "overlay")) {
|
|
2820
2894
|
return parent;
|
|
2821
2895
|
}
|
|
2822
2896
|
parent = parent.parentElement;
|
|
2823
2897
|
}
|
|
2824
|
-
return
|
|
2898
|
+
return ownerDocument;
|
|
2825
2899
|
};
|
|
2826
2900
|
var focusNearestParent = (element) => {
|
|
2827
2901
|
let parent = element.parentElement;
|
|
@@ -3159,6 +3233,9 @@ var setFeatureFlag = (flag, value) => {
|
|
|
3159
3233
|
console.error("unable to set feature flag", e);
|
|
3160
3234
|
}
|
|
3161
3235
|
};
|
|
3236
|
+
var oneOf = (needle, haystack) => {
|
|
3237
|
+
return haystack.includes(needle);
|
|
3238
|
+
};
|
|
3162
3239
|
|
|
3163
3240
|
// src/random.ts
|
|
3164
3241
|
var random = new Random(Date.now());
|
|
@@ -3169,6 +3246,16 @@ var reseed = (seed) => {
|
|
|
3169
3246
|
testIdBase = 0;
|
|
3170
3247
|
};
|
|
3171
3248
|
var randomId = () => isTestEnv() ? `id${testIdBase++}` : nanoid();
|
|
3249
|
+
var seededRandom = (seed) => {
|
|
3250
|
+
let value = seed >>> 0;
|
|
3251
|
+
return () => {
|
|
3252
|
+
value += 1831565813;
|
|
3253
|
+
let next = value;
|
|
3254
|
+
next = Math.imul(next ^ next >>> 15, next | 1);
|
|
3255
|
+
next ^= next + Math.imul(next ^ next >>> 7, next | 61);
|
|
3256
|
+
return ((next ^ next >>> 14) >>> 0) / 4294967296;
|
|
3257
|
+
};
|
|
3258
|
+
};
|
|
3172
3259
|
|
|
3173
3260
|
// src/url.ts
|
|
3174
3261
|
init_define_import_meta_env();
|
|
@@ -3232,6 +3319,298 @@ var Emitter = class {
|
|
|
3232
3319
|
this.subscribers = [];
|
|
3233
3320
|
}
|
|
3234
3321
|
};
|
|
3322
|
+
|
|
3323
|
+
// src/appEventBus.ts
|
|
3324
|
+
init_define_import_meta_env();
|
|
3325
|
+
var AppEventBus = class {
|
|
3326
|
+
constructor(behavior) {
|
|
3327
|
+
this.behavior = behavior;
|
|
3328
|
+
}
|
|
3329
|
+
emitters = /* @__PURE__ */ new Map();
|
|
3330
|
+
lastPayload = /* @__PURE__ */ new Map();
|
|
3331
|
+
emittedOnce = /* @__PURE__ */ new Set();
|
|
3332
|
+
getEmitter(name) {
|
|
3333
|
+
let emitter = this.emitters.get(name);
|
|
3334
|
+
if (!emitter) {
|
|
3335
|
+
emitter = new Emitter();
|
|
3336
|
+
this.emitters.set(name, emitter);
|
|
3337
|
+
}
|
|
3338
|
+
return emitter;
|
|
3339
|
+
}
|
|
3340
|
+
toPromiseValue(args) {
|
|
3341
|
+
return args.length === 1 ? args[0] : args;
|
|
3342
|
+
}
|
|
3343
|
+
on(name, callback) {
|
|
3344
|
+
const eventBehavior = this.behavior[name];
|
|
3345
|
+
const cachedPayload = this.lastPayload.get(name);
|
|
3346
|
+
if (callback) {
|
|
3347
|
+
if (eventBehavior.replay === "last" && cachedPayload) {
|
|
3348
|
+
queueMicrotask(() => callback(...cachedPayload));
|
|
3349
|
+
if (eventBehavior.cardinality === "once") {
|
|
3350
|
+
return () => {
|
|
3351
|
+
};
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
return this.getEmitter(name).on(callback);
|
|
3355
|
+
}
|
|
3356
|
+
if (eventBehavior.cardinality !== "once" || eventBehavior.replay !== "last") {
|
|
3357
|
+
throw new Error(`Event "${String(name)}" requires a callback`);
|
|
3358
|
+
}
|
|
3359
|
+
if (cachedPayload) {
|
|
3360
|
+
return Promise.resolve(this.toPromiseValue(cachedPayload));
|
|
3361
|
+
}
|
|
3362
|
+
return new Promise((resolve) => {
|
|
3363
|
+
this.getEmitter(name).once((...args) => {
|
|
3364
|
+
resolve(this.toPromiseValue(args));
|
|
3365
|
+
});
|
|
3366
|
+
});
|
|
3367
|
+
}
|
|
3368
|
+
emit(name, ...args) {
|
|
3369
|
+
const eventBehavior = this.behavior[name];
|
|
3370
|
+
if (!isProdEnv()) {
|
|
3371
|
+
if (eventBehavior.cardinality === "once") {
|
|
3372
|
+
if (this.emittedOnce.has(name)) {
|
|
3373
|
+
throw new Error(`Event "${String(name)}" can only be emitted once`);
|
|
3374
|
+
}
|
|
3375
|
+
this.emittedOnce.add(name);
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
if (eventBehavior.replay === "last") {
|
|
3379
|
+
this.lastPayload.set(name, args);
|
|
3380
|
+
}
|
|
3381
|
+
try {
|
|
3382
|
+
this.getEmitter(name).trigger(...args);
|
|
3383
|
+
} finally {
|
|
3384
|
+
if (eventBehavior.cardinality === "once") {
|
|
3385
|
+
this.getEmitter(name).clear();
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
}
|
|
3389
|
+
clear() {
|
|
3390
|
+
this.lastPayload.clear();
|
|
3391
|
+
this.emittedOnce.clear();
|
|
3392
|
+
for (const emitter of this.emitters.values()) {
|
|
3393
|
+
emitter.clear();
|
|
3394
|
+
}
|
|
3395
|
+
this.emitters.clear();
|
|
3396
|
+
}
|
|
3397
|
+
};
|
|
3398
|
+
|
|
3399
|
+
// src/versionedSnapshotStore.ts
|
|
3400
|
+
init_define_import_meta_env();
|
|
3401
|
+
var VersionedSnapshotStore = class {
|
|
3402
|
+
constructor(initialValue, isEqual = Object.is) {
|
|
3403
|
+
this.isEqual = isEqual;
|
|
3404
|
+
this.value = initialValue;
|
|
3405
|
+
}
|
|
3406
|
+
version = 0;
|
|
3407
|
+
value;
|
|
3408
|
+
waiters = /* @__PURE__ */ new Set();
|
|
3409
|
+
subscribers = /* @__PURE__ */ new Set();
|
|
3410
|
+
getSnapshot() {
|
|
3411
|
+
return { version: this.version, value: this.value };
|
|
3412
|
+
}
|
|
3413
|
+
set(nextValue) {
|
|
3414
|
+
if (this.isEqual(this.value, nextValue)) {
|
|
3415
|
+
return false;
|
|
3416
|
+
}
|
|
3417
|
+
this.value = nextValue;
|
|
3418
|
+
this.version += 1;
|
|
3419
|
+
const snapshot = this.getSnapshot();
|
|
3420
|
+
for (const subscriber of this.subscribers) {
|
|
3421
|
+
subscriber(snapshot);
|
|
3422
|
+
}
|
|
3423
|
+
for (const waiter of this.waiters) {
|
|
3424
|
+
waiter(snapshot);
|
|
3425
|
+
}
|
|
3426
|
+
this.waiters.clear();
|
|
3427
|
+
return true;
|
|
3428
|
+
}
|
|
3429
|
+
update(updater) {
|
|
3430
|
+
return this.set(updater(this.value));
|
|
3431
|
+
}
|
|
3432
|
+
subscribe(subscriber) {
|
|
3433
|
+
this.subscribers.add(subscriber);
|
|
3434
|
+
return () => {
|
|
3435
|
+
this.subscribers.delete(subscriber);
|
|
3436
|
+
};
|
|
3437
|
+
}
|
|
3438
|
+
pull(sinceVersion = -1) {
|
|
3439
|
+
if (this.version !== sinceVersion) {
|
|
3440
|
+
return Promise.resolve(this.getSnapshot());
|
|
3441
|
+
}
|
|
3442
|
+
return new Promise((resolve) => {
|
|
3443
|
+
this.waiters.add(resolve);
|
|
3444
|
+
});
|
|
3445
|
+
}
|
|
3446
|
+
};
|
|
3447
|
+
|
|
3448
|
+
// debug.ts
|
|
3449
|
+
init_define_import_meta_env();
|
|
3450
|
+
var lessPrecise = (num, precision = 5) => parseFloat(num.toPrecision(precision));
|
|
3451
|
+
var getAvgFrameTime = (times) => lessPrecise(times.reduce((a, b) => a + b) / times.length);
|
|
3452
|
+
var Debug = class _Debug {
|
|
3453
|
+
static DEBUG_LOG_TIMES = true;
|
|
3454
|
+
static TIMES_AGGR = {};
|
|
3455
|
+
static TIMES_AVG = {};
|
|
3456
|
+
static LAST_DEBUG_LOG_CALL = 0;
|
|
3457
|
+
static DEBUG_LOG_INTERVAL_ID = null;
|
|
3458
|
+
static LAST_FRAME_TIMESTAMP = 0;
|
|
3459
|
+
static FRAME_COUNT = 0;
|
|
3460
|
+
static ANIMATION_FRAME_ID = null;
|
|
3461
|
+
static scheduleAnimationFrame = () => {
|
|
3462
|
+
if (_Debug.DEBUG_LOG_INTERVAL_ID !== null) {
|
|
3463
|
+
_Debug.ANIMATION_FRAME_ID = requestAnimationFrame((timestamp) => {
|
|
3464
|
+
if (_Debug.LAST_FRAME_TIMESTAMP !== timestamp) {
|
|
3465
|
+
_Debug.LAST_FRAME_TIMESTAMP = timestamp;
|
|
3466
|
+
_Debug.FRAME_COUNT++;
|
|
3467
|
+
}
|
|
3468
|
+
if (_Debug.DEBUG_LOG_INTERVAL_ID !== null) {
|
|
3469
|
+
_Debug.scheduleAnimationFrame();
|
|
3470
|
+
}
|
|
3471
|
+
});
|
|
3472
|
+
}
|
|
3473
|
+
};
|
|
3474
|
+
static setupInterval = () => {
|
|
3475
|
+
if (_Debug.DEBUG_LOG_INTERVAL_ID === null) {
|
|
3476
|
+
console.info("%c(starting perf recording)", "color: lime");
|
|
3477
|
+
_Debug.DEBUG_LOG_INTERVAL_ID = window.setInterval(_Debug.debugLogger, 1e3);
|
|
3478
|
+
_Debug.scheduleAnimationFrame();
|
|
3479
|
+
}
|
|
3480
|
+
_Debug.LAST_DEBUG_LOG_CALL = Date.now();
|
|
3481
|
+
};
|
|
3482
|
+
static debugLogger = () => {
|
|
3483
|
+
if (_Debug.DEBUG_LOG_TIMES) {
|
|
3484
|
+
for (const [name, { t, times }] of Object.entries(_Debug.TIMES_AGGR)) {
|
|
3485
|
+
if (times.length) {
|
|
3486
|
+
console.info(
|
|
3487
|
+
name,
|
|
3488
|
+
lessPrecise(times.reduce((a, b) => a + b)),
|
|
3489
|
+
times.sort((a, b) => a - b).map((x) => lessPrecise(x))
|
|
3490
|
+
);
|
|
3491
|
+
_Debug.TIMES_AGGR[name] = { t, times: [] };
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3494
|
+
for (const [name, { t, times, avg }] of Object.entries(_Debug.TIMES_AVG)) {
|
|
3495
|
+
if (times.length) {
|
|
3496
|
+
const totalTime = times.reduce((a, b) => a + b);
|
|
3497
|
+
const avgFrameTime = lessPrecise(totalTime / _Debug.FRAME_COUNT);
|
|
3498
|
+
console.info(
|
|
3499
|
+
name,
|
|
3500
|
+
`- ${times.length} calls - ${avgFrameTime}ms/frame across ${_Debug.FRAME_COUNT} frames (${lessPrecise(
|
|
3501
|
+
avgFrameTime / 16.67 * 100,
|
|
3502
|
+
1
|
|
3503
|
+
)}% of frame budget)`
|
|
3504
|
+
);
|
|
3505
|
+
_Debug.TIMES_AVG[name] = {
|
|
3506
|
+
t,
|
|
3507
|
+
times: [],
|
|
3508
|
+
avg: avg != null ? getAvgFrameTime([avg, avgFrameTime]) : avgFrameTime
|
|
3509
|
+
};
|
|
3510
|
+
}
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
_Debug.FRAME_COUNT = 0;
|
|
3514
|
+
if (Date.now() - _Debug.LAST_DEBUG_LOG_CALL > 600 && _Debug.DEBUG_LOG_INTERVAL_ID !== null) {
|
|
3515
|
+
console.info("%c(stopping perf recording)", "color: red");
|
|
3516
|
+
window.clearInterval(_Debug.DEBUG_LOG_INTERVAL_ID);
|
|
3517
|
+
window.cancelAnimationFrame(_Debug.ANIMATION_FRAME_ID);
|
|
3518
|
+
_Debug.ANIMATION_FRAME_ID = null;
|
|
3519
|
+
_Debug.FRAME_COUNT = 0;
|
|
3520
|
+
_Debug.LAST_FRAME_TIMESTAMP = 0;
|
|
3521
|
+
_Debug.DEBUG_LOG_INTERVAL_ID = null;
|
|
3522
|
+
_Debug.TIMES_AGGR = {};
|
|
3523
|
+
_Debug.TIMES_AVG = {};
|
|
3524
|
+
}
|
|
3525
|
+
};
|
|
3526
|
+
static logTime = (time, name = "default") => {
|
|
3527
|
+
_Debug.setupInterval();
|
|
3528
|
+
const now = performance.now();
|
|
3529
|
+
const { t, times } = _Debug.TIMES_AGGR[name] = _Debug.TIMES_AGGR[name] || {
|
|
3530
|
+
t: 0,
|
|
3531
|
+
times: []
|
|
3532
|
+
};
|
|
3533
|
+
if (t) {
|
|
3534
|
+
times.push(time != null ? time : now - t);
|
|
3535
|
+
}
|
|
3536
|
+
_Debug.TIMES_AGGR[name].t = now;
|
|
3537
|
+
};
|
|
3538
|
+
static logTimeAverage = (time, name = "default") => {
|
|
3539
|
+
_Debug.setupInterval();
|
|
3540
|
+
const now = performance.now();
|
|
3541
|
+
const { t, times } = _Debug.TIMES_AVG[name] = _Debug.TIMES_AVG[name] || {
|
|
3542
|
+
t: 0,
|
|
3543
|
+
times: []
|
|
3544
|
+
};
|
|
3545
|
+
if (t) {
|
|
3546
|
+
times.push(time != null ? time : now - t);
|
|
3547
|
+
}
|
|
3548
|
+
_Debug.TIMES_AVG[name].t = now;
|
|
3549
|
+
};
|
|
3550
|
+
static logWrapper = (type) => (fn, name = "default") => {
|
|
3551
|
+
return (...args) => {
|
|
3552
|
+
const t0 = performance.now();
|
|
3553
|
+
const ret = fn(...args);
|
|
3554
|
+
_Debug[type](performance.now() - t0, name);
|
|
3555
|
+
return ret;
|
|
3556
|
+
};
|
|
3557
|
+
};
|
|
3558
|
+
static logTimeWrap = _Debug.logWrapper("logTime");
|
|
3559
|
+
static logTimeAverageWrap = _Debug.logWrapper("logTimeAverage");
|
|
3560
|
+
static perfWrap = (fn, name = "default") => {
|
|
3561
|
+
return (...args) => {
|
|
3562
|
+
console.time(name);
|
|
3563
|
+
const ret = fn(...args);
|
|
3564
|
+
console.timeEnd(name);
|
|
3565
|
+
return ret;
|
|
3566
|
+
};
|
|
3567
|
+
};
|
|
3568
|
+
static CHANGED_CACHE = {};
|
|
3569
|
+
static logChanged(name, obj) {
|
|
3570
|
+
const prev = _Debug.CHANGED_CACHE[name];
|
|
3571
|
+
_Debug.CHANGED_CACHE[name] = obj;
|
|
3572
|
+
if (!prev) {
|
|
3573
|
+
return;
|
|
3574
|
+
}
|
|
3575
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(obj)]);
|
|
3576
|
+
const changed = {};
|
|
3577
|
+
for (const key of allKeys) {
|
|
3578
|
+
const prevVal = prev[key];
|
|
3579
|
+
const nextVal = obj[key];
|
|
3580
|
+
if (!deepEqual(prevVal, nextVal)) {
|
|
3581
|
+
changed[key] = { prev: prevVal, next: nextVal };
|
|
3582
|
+
}
|
|
3583
|
+
}
|
|
3584
|
+
if (Object.keys(changed).length > 0) {
|
|
3585
|
+
console.info(`[${name}] changed:`, changed);
|
|
3586
|
+
}
|
|
3587
|
+
}
|
|
3588
|
+
};
|
|
3589
|
+
function deepEqual(a, b) {
|
|
3590
|
+
if (Object.is(a, b)) {
|
|
3591
|
+
return true;
|
|
3592
|
+
}
|
|
3593
|
+
if (a === null || b === null || typeof a !== "object" || typeof b !== "object") {
|
|
3594
|
+
return false;
|
|
3595
|
+
}
|
|
3596
|
+
if (Array.isArray(a) !== Array.isArray(b)) {
|
|
3597
|
+
return false;
|
|
3598
|
+
}
|
|
3599
|
+
const keysA = Object.keys(a);
|
|
3600
|
+
const keysB = Object.keys(b);
|
|
3601
|
+
if (keysA.length !== keysB.length) {
|
|
3602
|
+
return false;
|
|
3603
|
+
}
|
|
3604
|
+
for (const key of keysA) {
|
|
3605
|
+
if (!deepEqual(
|
|
3606
|
+
a[key],
|
|
3607
|
+
b[key]
|
|
3608
|
+
)) {
|
|
3609
|
+
return false;
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
return true;
|
|
3613
|
+
}
|
|
3235
3614
|
export {
|
|
3236
3615
|
ACTIVE_THRESHOLD,
|
|
3237
3616
|
ALLOWED_PASTE_MIME_TYPES,
|
|
@@ -3239,8 +3618,10 @@ export {
|
|
|
3239
3618
|
ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO,
|
|
3240
3619
|
ARROW_LABEL_WIDTH_FRACTION,
|
|
3241
3620
|
ARROW_TYPE,
|
|
3621
|
+
AppEventBus,
|
|
3242
3622
|
BIND_MODE_TIMEOUT,
|
|
3243
3623
|
BOUND_TEXT_PADDING,
|
|
3624
|
+
BUCKET_FILL_BACKGROUND_PICKS,
|
|
3244
3625
|
BinaryHeap,
|
|
3245
3626
|
CANVAS_ONLY_ACTIONS,
|
|
3246
3627
|
CANVAS_SEARCH_TAB,
|
|
@@ -3251,6 +3632,7 @@ export {
|
|
|
3251
3632
|
COLOR_CHARCOAL_BLACK,
|
|
3252
3633
|
COLOR_OUTLINE_CONTRAST_THRESHOLD,
|
|
3253
3634
|
COLOR_PALETTE,
|
|
3635
|
+
COLOR_TOP_PICKS_SLOTS,
|
|
3254
3636
|
COLOR_VOICE_CALL,
|
|
3255
3637
|
COLOR_WHITE,
|
|
3256
3638
|
CURSOR_TYPE,
|
|
@@ -3266,26 +3648,34 @@ export {
|
|
|
3266
3648
|
DEFAULT_ELEMENT_STROKE_COLOR_INDEX,
|
|
3267
3649
|
DEFAULT_ELEMENT_STROKE_COLOR_PALETTE,
|
|
3268
3650
|
DEFAULT_ELEMENT_STROKE_PICKS,
|
|
3651
|
+
DEFAULT_ELEMENT_STROKE_WIDTH_KEY,
|
|
3269
3652
|
DEFAULT_EXPORT_PADDING,
|
|
3270
3653
|
DEFAULT_FILENAME,
|
|
3271
3654
|
DEFAULT_FONT_FAMILY,
|
|
3272
3655
|
DEFAULT_FONT_SIZE,
|
|
3273
3656
|
DEFAULT_GRID_SIZE,
|
|
3274
3657
|
DEFAULT_GRID_STEP,
|
|
3658
|
+
DEFAULT_IMAGE_OPTIONS,
|
|
3275
3659
|
DEFAULT_LASER_COLOR,
|
|
3276
|
-
DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT,
|
|
3277
3660
|
DEFAULT_PROPORTIONAL_RADIUS,
|
|
3278
3661
|
DEFAULT_REDUCED_GLOBAL_ALPHA,
|
|
3279
3662
|
DEFAULT_SIDEBAR,
|
|
3663
|
+
DEFAULT_STICKY_NOTE_BG,
|
|
3664
|
+
DEFAULT_STICKY_NOTE_SIZE,
|
|
3665
|
+
DEFAULT_STROKE_STREAMLINE,
|
|
3666
|
+
DEFAULT_STROKE_STREAMLINE_PRECISE,
|
|
3280
3667
|
DEFAULT_TEXT_ALIGN,
|
|
3281
3668
|
DEFAULT_TRANSFORM_HANDLE_SPACING,
|
|
3282
3669
|
DEFAULT_UI_OPTIONS,
|
|
3283
3670
|
DEFAULT_VERSION,
|
|
3284
3671
|
DEFAULT_VERTICAL_ALIGN,
|
|
3672
|
+
DEFAULT_ZOOM,
|
|
3285
3673
|
DOUBLE_TAP_POSITION_THRESHOLD,
|
|
3286
3674
|
DRAGGING_THRESHOLD,
|
|
3675
|
+
Debug,
|
|
3287
3676
|
EDITOR_LS_KEYS,
|
|
3288
3677
|
ELEMENT_LINK_KEY,
|
|
3678
|
+
ELEMENT_PENDING_DRAW_SHAPE_OPACITY,
|
|
3289
3679
|
ELEMENT_READY_TO_ERASE_OPACITY,
|
|
3290
3680
|
ELEMENT_SHIFT_TRANSLATE_AMOUNT,
|
|
3291
3681
|
ELEMENT_TRANSLATE_AMOUNT,
|
|
@@ -3302,7 +3692,9 @@ export {
|
|
|
3302
3692
|
FONT_FAMILY_GENERIC_FALLBACKS,
|
|
3303
3693
|
FONT_METADATA,
|
|
3304
3694
|
FONT_SIZES,
|
|
3695
|
+
FONT_TOP_PICKS_SLOTS,
|
|
3305
3696
|
FRAME_STYLE,
|
|
3697
|
+
FREEDRAW_STROKE_WIDTH,
|
|
3306
3698
|
GOOGLE_FONTS_RANGES,
|
|
3307
3699
|
HYPERLINK_TOOLTIP_DELAY,
|
|
3308
3700
|
IDLE_THRESHOLD,
|
|
@@ -3315,7 +3707,6 @@ export {
|
|
|
3315
3707
|
LINE_CONFIRM_THRESHOLD,
|
|
3316
3708
|
LINE_POLYGON_POINT_MERGE_DISTANCE,
|
|
3317
3709
|
LOCAL_FONT_PROTOCOL,
|
|
3318
|
-
MAX_ALLOWED_FILE_BYTES,
|
|
3319
3710
|
MAX_CUSTOM_COLORS_USED_IN_CANVAS,
|
|
3320
3711
|
MAX_DECIMALS_FOR_SVG_EXPORT,
|
|
3321
3712
|
MAX_ZOOM,
|
|
@@ -3345,14 +3736,31 @@ export {
|
|
|
3345
3736
|
SHIFT_LOCKING_ANGLE,
|
|
3346
3737
|
SIDE_RESIZING_THRESHOLD,
|
|
3347
3738
|
STATS_PANELS,
|
|
3739
|
+
STICKY_NOTE_BACKGROUND_PICKS,
|
|
3740
|
+
STICKY_NOTE_BODY_INSET_Y,
|
|
3741
|
+
STICKY_NOTE_EDGE_SHADOW_OPACITY,
|
|
3742
|
+
STICKY_NOTE_EDGE_SHADOW_WIDTH,
|
|
3743
|
+
STICKY_NOTE_FALLBACK_FONT_SIZE,
|
|
3744
|
+
STICKY_NOTE_FONT_STEP,
|
|
3745
|
+
STICKY_NOTE_FOOTER,
|
|
3746
|
+
STICKY_NOTE_MAX_FONT_SIZE,
|
|
3747
|
+
STICKY_NOTE_MIN_FONT_SIZE,
|
|
3748
|
+
STICKY_NOTE_MIN_SIZE,
|
|
3749
|
+
STICKY_NOTE_PADDING,
|
|
3750
|
+
STICKY_NOTE_SHADOW_OFFSET,
|
|
3751
|
+
STICKY_NOTE_SHADOW_OPACITY,
|
|
3752
|
+
STICKY_NOTE_STROKE_PICKS,
|
|
3348
3753
|
STRING_MIME_TYPES,
|
|
3349
3754
|
STROKE_WIDTH,
|
|
3755
|
+
STROKE_WIDTH_KEYS,
|
|
3350
3756
|
SVG_DOCUMENT_PREAMBLE,
|
|
3351
3757
|
SVG_NS,
|
|
3352
3758
|
TAP_TWICE_TIMEOUT,
|
|
3353
3759
|
TEXT_ALIGN,
|
|
3354
3760
|
TEXT_AUTOWRAP_THRESHOLD,
|
|
3761
|
+
TEXT_MAX_WRAP_WIDTH,
|
|
3355
3762
|
TEXT_TO_CENTER_SNAP_THRESHOLD,
|
|
3763
|
+
TEXT_VIEWPORT_PADDING,
|
|
3356
3764
|
THEME,
|
|
3357
3765
|
TITLE_TIMEOUT,
|
|
3358
3766
|
TOOL_TYPE,
|
|
@@ -3363,8 +3771,10 @@ export {
|
|
|
3363
3771
|
VERSIONS,
|
|
3364
3772
|
VERSION_TIMEOUT,
|
|
3365
3773
|
VERTICAL_ALIGN,
|
|
3774
|
+
VersionedSnapshotStore,
|
|
3366
3775
|
WINDOWS_EMOJI_FALLBACK_FONT,
|
|
3367
3776
|
YOUTUBE_STATES,
|
|
3777
|
+
ZEN_MODE_TRANSITION_DURATION,
|
|
3368
3778
|
ZOOM_STEP,
|
|
3369
3779
|
addEventListener,
|
|
3370
3780
|
allowFullScreen,
|
|
@@ -3386,7 +3796,6 @@ export {
|
|
|
3386
3796
|
deriveStylesPanelMode,
|
|
3387
3797
|
distance,
|
|
3388
3798
|
easeOut,
|
|
3389
|
-
easeToValuesRAF,
|
|
3390
3799
|
escapeDoubleQuotes,
|
|
3391
3800
|
exitFullScreen,
|
|
3392
3801
|
findIndex,
|
|
@@ -3407,10 +3816,13 @@ export {
|
|
|
3407
3816
|
getLineHeight,
|
|
3408
3817
|
getNearestScrollableContainer,
|
|
3409
3818
|
getSizeFromPoints,
|
|
3819
|
+
getStrokeWidthByKey,
|
|
3410
3820
|
getSvgPathFromStroke,
|
|
3821
|
+
getTargetWindow,
|
|
3411
3822
|
getUpdatedTimestamp,
|
|
3412
3823
|
getVersion,
|
|
3413
3824
|
getVerticalOffset,
|
|
3825
|
+
hasRTLChars,
|
|
3414
3826
|
invariant,
|
|
3415
3827
|
isAndroid,
|
|
3416
3828
|
isAnyTrue,
|
|
@@ -3430,6 +3842,7 @@ export {
|
|
|
3430
3842
|
isLocalLink,
|
|
3431
3843
|
isMemberOf,
|
|
3432
3844
|
isMobileBreakpoint,
|
|
3845
|
+
isOpaqueColor,
|
|
3433
3846
|
isPrimitive,
|
|
3434
3847
|
isProdEnv,
|
|
3435
3848
|
isPromiseLike,
|
|
@@ -3456,12 +3869,14 @@ export {
|
|
|
3456
3869
|
normalizeEOL,
|
|
3457
3870
|
normalizeInputColor,
|
|
3458
3871
|
normalizeLink,
|
|
3872
|
+
oneOf,
|
|
3459
3873
|
preventUnload,
|
|
3460
3874
|
promiseTry,
|
|
3461
3875
|
queryFocusableElements,
|
|
3462
3876
|
randomId,
|
|
3463
3877
|
randomInteger,
|
|
3464
3878
|
reduceToCommonValue,
|
|
3879
|
+
removeDarkModeFilter,
|
|
3465
3880
|
removeSelection,
|
|
3466
3881
|
rescalePoints,
|
|
3467
3882
|
reseed,
|
|
@@ -3469,7 +3884,9 @@ export {
|
|
|
3469
3884
|
rgbToHex2 as rgbToHex,
|
|
3470
3885
|
safelyParseJSON,
|
|
3471
3886
|
sceneCoordsToViewportCoords,
|
|
3887
|
+
seededRandom,
|
|
3472
3888
|
selectNode,
|
|
3889
|
+
setColorAlpha,
|
|
3473
3890
|
setDateTimeForTests,
|
|
3474
3891
|
setDesktopUIMode,
|
|
3475
3892
|
setFeatureFlag,
|