@excalidraw/common 0.18.0-6135548 → 0.18.0-699826
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 +324 -26
- package/dist/dev/index.js.map +3 -3
- 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 +14 -14
- package/dist/types/common/src/constants.d.ts +5 -2
- package/dist/types/common/src/index.d.ts +3 -0
- package/dist/types/common/src/utils.d.ts +4 -7
- package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
- package/dist/types/element/src/Scene.d.ts +7 -3
- package/dist/types/element/src/arrowheads.d.ts +3 -0
- package/dist/types/element/src/arrows/focus.d.ts +27 -0
- package/dist/types/element/src/arrows/helpers.d.ts +5 -0
- package/dist/types/element/src/binding.d.ts +13 -8
- package/dist/types/element/src/bounds.d.ts +22 -3
- package/dist/types/element/src/collision.d.ts +4 -3
- package/dist/types/element/src/distribute.d.ts +2 -1
- package/dist/types/element/src/duplicate.d.ts +1 -0
- package/dist/types/element/src/elbowArrow.d.ts +2 -0
- package/dist/types/element/src/frame.d.ts +7 -6
- package/dist/types/element/src/index.d.ts +3 -0
- package/dist/types/element/src/linearElementEditor.d.ts +7 -2
- package/dist/types/element/src/mutateElement.d.ts +2 -0
- package/dist/types/element/src/selection.d.ts +8 -4
- package/dist/types/element/src/shape.d.ts +1 -1
- package/dist/types/element/src/textElement.d.ts +1 -1
- package/dist/types/element/src/textWrapping.d.ts +26 -0
- package/dist/types/element/src/typeChecks.d.ts +1 -0
- package/dist/types/element/src/types.d.ts +5 -2
- package/dist/types/element/src/utils.d.ts +6 -4
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +41 -38
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +29 -27
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +228 -216
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +28 -26
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +14 -13
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +45 -40
- package/dist/types/excalidraw/actions/actionDeselect.d.ts +159 -0
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +10 -13
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +28 -26
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +14 -13
- package/dist/types/excalidraw/actions/actionExport.d.ts +116 -388
- package/dist/types/excalidraw/actions/actionFrame.d.ts +56 -52
- package/dist/types/excalidraw/actions/actionGroup.d.ts +31 -29
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +16 -13
- package/dist/types/excalidraw/actions/actionLink.d.ts +14 -13
- package/dist/types/excalidraw/actions/actionMenu.d.ts +10 -13
- package/dist/types/excalidraw/actions/actionProperties.d.ts +31 -29
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +15 -14
- package/dist/types/excalidraw/actions/actionStyles.d.ts +14 -12
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +172 -0
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +14 -13
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +172 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +14 -13
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +10 -13
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +14 -13
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +14 -13
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +14 -13
- package/dist/types/excalidraw/actions/index.d.ts +3 -0
- package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
- package/dist/types/excalidraw/actions/types.d.ts +1 -1
- package/dist/types/excalidraw/{animated-trail.d.ts → animatedTrail.d.ts} +4 -3
- package/dist/types/excalidraw/appState.d.ts +30 -27
- package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
- package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
- package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
- package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
- package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
- package/dist/types/excalidraw/charts/index.d.ts +7 -0
- package/dist/types/excalidraw/clipboard.d.ts +8 -9
- package/dist/types/excalidraw/components/App.d.ts +63 -16
- package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
- 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/IconPicker.d.ts +14 -9
- package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
- package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -1
- 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/TTDDialog/Chat/ChatInterface.d.ts +2 -6
- package/dist/types/excalidraw/components/TTDDialog/Chat/TTDChatPanel.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
- package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +11 -7
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
- package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
- package/dist/types/excalidraw/components/TTDDialog/TTDWelcomeMessage.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
- package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
- package/dist/types/excalidraw/components/TTDDialog/types.d.ts +4 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
- package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
- package/dist/types/excalidraw/components/Toast.d.ts +8 -4
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +2 -1
- package/dist/types/excalidraw/components/canvases/NewElementCanvas.d.ts +1 -0
- package/dist/types/excalidraw/components/canvases/StaticCanvas.d.ts +1 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +30 -17
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +3 -2
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +11 -13
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContentRadio.d.ts +2 -1
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
- package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
- package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +1 -1
- package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
- package/dist/types/excalidraw/components/icons.d.ts +23 -9
- package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +24 -3
- package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +23 -13
- package/dist/types/excalidraw/components/shapes.d.ts +81 -1
- package/dist/types/excalidraw/data/blob.d.ts +169 -168
- package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
- package/dist/types/excalidraw/data/index.d.ts +2 -3
- package/dist/types/excalidraw/data/json.d.ts +94 -85
- package/dist/types/excalidraw/data/resave.d.ts +7 -2
- package/dist/types/excalidraw/eraser/index.d.ts +2 -3
- 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/renderer/animation.d.ts +4 -1
- package/dist/types/excalidraw/scene/Renderer.d.ts +425 -19
- package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
- package/dist/types/excalidraw/types.d.ts +116 -18
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +5 -1
- package/dist/types/fractional-indexing/src/index.d.ts +29 -0
- package/dist/types/math/src/constants.d.ts +0 -1
- package/dist/types/math/src/curve.d.ts +4 -1
- package/dist/types/math/src/point.d.ts +8 -2
- package/dist/types/math/src/types.d.ts +25 -1
- package/dist/types/utils/src/index.d.ts +1 -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/InitializeApp.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/footer/FooterCenter.d.ts +0 -8
- package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -11
- 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/data/reconcile.d.ts +0 -7
- package/dist/types/excalidraw/index.d.ts +0 -46
- package/dist/types/excalidraw/polyfill.d.ts +0 -2
- package/dist/types/utils/src/bbox.d.ts +0 -9
- package/dist/types/utils/src/withinBounds.d.ts +0 -19
package/dist/dev/index.js
CHANGED
|
@@ -1394,7 +1394,10 @@ var cssInvert = (r, g, b, percent) => {
|
|
|
1394
1394
|
const invertedB = invertComponent(b);
|
|
1395
1395
|
return { r: invertedR, g: invertedG, b: invertedB };
|
|
1396
1396
|
};
|
|
1397
|
-
var applyDarkModeFilter = (color) => {
|
|
1397
|
+
var applyDarkModeFilter = (color, enable = true) => {
|
|
1398
|
+
if (!enable) {
|
|
1399
|
+
return color;
|
|
1400
|
+
}
|
|
1398
1401
|
const cached = DARK_MODE_COLORS_CACHE?.get(color);
|
|
1399
1402
|
if (cached) {
|
|
1400
1403
|
return cached;
|
|
@@ -1562,7 +1565,7 @@ var normalizeInputColor = (color) => {
|
|
|
1562
1565
|
}
|
|
1563
1566
|
const tc = tinycolor(color);
|
|
1564
1567
|
if (tc.isValid()) {
|
|
1565
|
-
if (tc.getFormat()
|
|
1568
|
+
if (["hex", "hex8"].includes(tc.getFormat()) && !color.startsWith("#")) {
|
|
1566
1569
|
return `#${color}`;
|
|
1567
1570
|
}
|
|
1568
1571
|
return color;
|
|
@@ -1659,7 +1662,8 @@ var CLASSES = {
|
|
|
1659
1662
|
SEARCH_MENU_INPUT_WRAPPER: "layer-ui__search-inputWrapper",
|
|
1660
1663
|
CONVERT_ELEMENT_TYPE_POPUP: "ConvertElementTypePopup",
|
|
1661
1664
|
SHAPE_ACTIONS_THEME_SCOPE: "shape-actions-theme-scope",
|
|
1662
|
-
FRAME_NAME: "frame-name"
|
|
1665
|
+
FRAME_NAME: "frame-name",
|
|
1666
|
+
DROPDOWN_MENU_EVENT_WRAPPER: "dropdown-menu-event-wrapper"
|
|
1663
1667
|
};
|
|
1664
1668
|
var FONT_SIZES = {
|
|
1665
1669
|
sm: 16,
|
|
@@ -1718,6 +1722,7 @@ var THEME = {
|
|
|
1718
1722
|
LIGHT: "light",
|
|
1719
1723
|
DARK: "dark"
|
|
1720
1724
|
};
|
|
1725
|
+
var DARK_THEME_FILTER = "invert(93%) hue-rotate(180deg)";
|
|
1721
1726
|
var FRAME_STYLE = {
|
|
1722
1727
|
strokeColor: "#bbb",
|
|
1723
1728
|
strokeWidth: 2,
|
|
@@ -1766,6 +1771,7 @@ var STRING_MIME_TYPES = {
|
|
|
1766
1771
|
json: "application/json",
|
|
1767
1772
|
// excalidraw data
|
|
1768
1773
|
excalidraw: "application/vnd.excalidraw+json",
|
|
1774
|
+
excalidrawClipboard: "application/vnd.excalidraw.clipboard+json",
|
|
1769
1775
|
// LEGACY: fully-qualified library JSON data
|
|
1770
1776
|
excalidrawlib: "application/vnd.excalidrawlib+json",
|
|
1771
1777
|
// list of excalidraw library item ids
|
|
@@ -1833,8 +1839,10 @@ var DEFAULT_UI_OPTIONS = {
|
|
|
1833
1839
|
var MAX_DECIMALS_FOR_SVG_EXPORT = 2;
|
|
1834
1840
|
var EXPORT_SCALES = [1, 2, 3];
|
|
1835
1841
|
var DEFAULT_EXPORT_PADDING = 10;
|
|
1836
|
-
var
|
|
1837
|
-
|
|
1842
|
+
var DEFAULT_IMAGE_OPTIONS = {
|
|
1843
|
+
maxWidthOrHeight: 1440,
|
|
1844
|
+
maxFileSizeBytes: 4 * 1024 * 1024
|
|
1845
|
+
};
|
|
1838
1846
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
1839
1847
|
var SVG_DOCUMENT_PREAMBLE = `<?xml version="1.0" standalone="no"?>
|
|
1840
1848
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
@@ -2481,7 +2489,7 @@ var isInteractive = (target) => {
|
|
|
2481
2489
|
return isInputLike(target) || target instanceof Element && !!target.closest("label, button");
|
|
2482
2490
|
};
|
|
2483
2491
|
var isWritableElement = (target) => target instanceof HTMLElement && target.dataset.type === "wysiwyg" || target instanceof HTMLBRElement || // newline in wysiwyg
|
|
2484
|
-
target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password" || target.type === "search");
|
|
2492
|
+
target instanceof HTMLTextAreaElement || target instanceof HTMLInputElement && (target.type === "text" || target.type === "number" || target.type === "password" || target.type === "search") || target instanceof HTMLElement && target.closest(".cm-editor") !== null;
|
|
2485
2493
|
var getFontFamilyString = ({
|
|
2486
2494
|
fontFamily
|
|
2487
2495
|
}) => {
|
|
@@ -2526,32 +2534,23 @@ var debounce = (fn, timeout) => {
|
|
|
2526
2534
|
};
|
|
2527
2535
|
return ret;
|
|
2528
2536
|
};
|
|
2529
|
-
var throttleRAF = (fn
|
|
2537
|
+
var throttleRAF = (fn) => {
|
|
2530
2538
|
let timerId = null;
|
|
2531
2539
|
let lastArgs = null;
|
|
2532
|
-
|
|
2533
|
-
const scheduleFunc = (args) => {
|
|
2540
|
+
const scheduleFunc = () => {
|
|
2534
2541
|
timerId = window.requestAnimationFrame(() => {
|
|
2535
2542
|
timerId = null;
|
|
2536
|
-
|
|
2543
|
+
const args = lastArgs;
|
|
2537
2544
|
lastArgs = null;
|
|
2538
|
-
if (
|
|
2539
|
-
|
|
2540
|
-
lastArgsTrailing = null;
|
|
2541
|
-
scheduleFunc(lastArgs);
|
|
2545
|
+
if (args) {
|
|
2546
|
+
fn(...args);
|
|
2542
2547
|
}
|
|
2543
2548
|
});
|
|
2544
2549
|
};
|
|
2545
2550
|
const ret = (...args) => {
|
|
2546
|
-
if (isTestEnv()) {
|
|
2547
|
-
fn(...args);
|
|
2548
|
-
return;
|
|
2549
|
-
}
|
|
2550
2551
|
lastArgs = args;
|
|
2551
2552
|
if (timerId === null) {
|
|
2552
|
-
scheduleFunc(
|
|
2553
|
-
} else if (opts?.trailing) {
|
|
2554
|
-
lastArgsTrailing = args;
|
|
2553
|
+
scheduleFunc();
|
|
2555
2554
|
}
|
|
2556
2555
|
};
|
|
2557
2556
|
ret.flush = () => {
|
|
@@ -2560,12 +2559,12 @@ var throttleRAF = (fn, opts) => {
|
|
|
2560
2559
|
timerId = null;
|
|
2561
2560
|
}
|
|
2562
2561
|
if (lastArgs) {
|
|
2563
|
-
fn(...
|
|
2564
|
-
lastArgs =
|
|
2562
|
+
fn(...lastArgs);
|
|
2563
|
+
lastArgs = null;
|
|
2565
2564
|
}
|
|
2566
2565
|
};
|
|
2567
2566
|
ret.cancel = () => {
|
|
2568
|
-
lastArgs =
|
|
2567
|
+
lastArgs = null;
|
|
2569
2568
|
if (timerId !== null) {
|
|
2570
2569
|
cancelAnimationFrame(timerId);
|
|
2571
2570
|
timerId = null;
|
|
@@ -3156,6 +3155,9 @@ var setFeatureFlag = (flag, value) => {
|
|
|
3156
3155
|
console.error("unable to set feature flag", e);
|
|
3157
3156
|
}
|
|
3158
3157
|
};
|
|
3158
|
+
var oneOf = (needle, haystack) => {
|
|
3159
|
+
return haystack.includes(needle);
|
|
3160
|
+
};
|
|
3159
3161
|
|
|
3160
3162
|
// src/random.ts
|
|
3161
3163
|
var random = new Random(Date.now());
|
|
@@ -3229,6 +3231,298 @@ var Emitter = class {
|
|
|
3229
3231
|
this.subscribers = [];
|
|
3230
3232
|
}
|
|
3231
3233
|
};
|
|
3234
|
+
|
|
3235
|
+
// src/appEventBus.ts
|
|
3236
|
+
init_define_import_meta_env();
|
|
3237
|
+
var AppEventBus = class {
|
|
3238
|
+
constructor(behavior) {
|
|
3239
|
+
this.behavior = behavior;
|
|
3240
|
+
}
|
|
3241
|
+
emitters = /* @__PURE__ */ new Map();
|
|
3242
|
+
lastPayload = /* @__PURE__ */ new Map();
|
|
3243
|
+
emittedOnce = /* @__PURE__ */ new Set();
|
|
3244
|
+
getEmitter(name) {
|
|
3245
|
+
let emitter = this.emitters.get(name);
|
|
3246
|
+
if (!emitter) {
|
|
3247
|
+
emitter = new Emitter();
|
|
3248
|
+
this.emitters.set(name, emitter);
|
|
3249
|
+
}
|
|
3250
|
+
return emitter;
|
|
3251
|
+
}
|
|
3252
|
+
toPromiseValue(args) {
|
|
3253
|
+
return args.length === 1 ? args[0] : args;
|
|
3254
|
+
}
|
|
3255
|
+
on(name, callback) {
|
|
3256
|
+
const eventBehavior = this.behavior[name];
|
|
3257
|
+
const cachedPayload = this.lastPayload.get(name);
|
|
3258
|
+
if (callback) {
|
|
3259
|
+
if (eventBehavior.replay === "last" && cachedPayload) {
|
|
3260
|
+
queueMicrotask(() => callback(...cachedPayload));
|
|
3261
|
+
if (eventBehavior.cardinality === "once") {
|
|
3262
|
+
return () => {
|
|
3263
|
+
};
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3266
|
+
return this.getEmitter(name).on(callback);
|
|
3267
|
+
}
|
|
3268
|
+
if (eventBehavior.cardinality !== "once" || eventBehavior.replay !== "last") {
|
|
3269
|
+
throw new Error(`Event "${String(name)}" requires a callback`);
|
|
3270
|
+
}
|
|
3271
|
+
if (cachedPayload) {
|
|
3272
|
+
return Promise.resolve(this.toPromiseValue(cachedPayload));
|
|
3273
|
+
}
|
|
3274
|
+
return new Promise((resolve) => {
|
|
3275
|
+
this.getEmitter(name).once((...args) => {
|
|
3276
|
+
resolve(this.toPromiseValue(args));
|
|
3277
|
+
});
|
|
3278
|
+
});
|
|
3279
|
+
}
|
|
3280
|
+
emit(name, ...args) {
|
|
3281
|
+
const eventBehavior = this.behavior[name];
|
|
3282
|
+
if (!isProdEnv()) {
|
|
3283
|
+
if (eventBehavior.cardinality === "once") {
|
|
3284
|
+
if (this.emittedOnce.has(name)) {
|
|
3285
|
+
throw new Error(`Event "${String(name)}" can only be emitted once`);
|
|
3286
|
+
}
|
|
3287
|
+
this.emittedOnce.add(name);
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
if (eventBehavior.replay === "last") {
|
|
3291
|
+
this.lastPayload.set(name, args);
|
|
3292
|
+
}
|
|
3293
|
+
try {
|
|
3294
|
+
this.getEmitter(name).trigger(...args);
|
|
3295
|
+
} finally {
|
|
3296
|
+
if (eventBehavior.cardinality === "once") {
|
|
3297
|
+
this.getEmitter(name).clear();
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
clear() {
|
|
3302
|
+
this.lastPayload.clear();
|
|
3303
|
+
this.emittedOnce.clear();
|
|
3304
|
+
for (const emitter of this.emitters.values()) {
|
|
3305
|
+
emitter.clear();
|
|
3306
|
+
}
|
|
3307
|
+
this.emitters.clear();
|
|
3308
|
+
}
|
|
3309
|
+
};
|
|
3310
|
+
|
|
3311
|
+
// src/versionedSnapshotStore.ts
|
|
3312
|
+
init_define_import_meta_env();
|
|
3313
|
+
var VersionedSnapshotStore = class {
|
|
3314
|
+
constructor(initialValue, isEqual = Object.is) {
|
|
3315
|
+
this.isEqual = isEqual;
|
|
3316
|
+
this.value = initialValue;
|
|
3317
|
+
}
|
|
3318
|
+
version = 0;
|
|
3319
|
+
value;
|
|
3320
|
+
waiters = /* @__PURE__ */ new Set();
|
|
3321
|
+
subscribers = /* @__PURE__ */ new Set();
|
|
3322
|
+
getSnapshot() {
|
|
3323
|
+
return { version: this.version, value: this.value };
|
|
3324
|
+
}
|
|
3325
|
+
set(nextValue) {
|
|
3326
|
+
if (this.isEqual(this.value, nextValue)) {
|
|
3327
|
+
return false;
|
|
3328
|
+
}
|
|
3329
|
+
this.value = nextValue;
|
|
3330
|
+
this.version += 1;
|
|
3331
|
+
const snapshot = this.getSnapshot();
|
|
3332
|
+
for (const subscriber of this.subscribers) {
|
|
3333
|
+
subscriber(snapshot);
|
|
3334
|
+
}
|
|
3335
|
+
for (const waiter of this.waiters) {
|
|
3336
|
+
waiter(snapshot);
|
|
3337
|
+
}
|
|
3338
|
+
this.waiters.clear();
|
|
3339
|
+
return true;
|
|
3340
|
+
}
|
|
3341
|
+
update(updater) {
|
|
3342
|
+
return this.set(updater(this.value));
|
|
3343
|
+
}
|
|
3344
|
+
subscribe(subscriber) {
|
|
3345
|
+
this.subscribers.add(subscriber);
|
|
3346
|
+
return () => {
|
|
3347
|
+
this.subscribers.delete(subscriber);
|
|
3348
|
+
};
|
|
3349
|
+
}
|
|
3350
|
+
pull(sinceVersion = -1) {
|
|
3351
|
+
if (this.version !== sinceVersion) {
|
|
3352
|
+
return Promise.resolve(this.getSnapshot());
|
|
3353
|
+
}
|
|
3354
|
+
return new Promise((resolve) => {
|
|
3355
|
+
this.waiters.add(resolve);
|
|
3356
|
+
});
|
|
3357
|
+
}
|
|
3358
|
+
};
|
|
3359
|
+
|
|
3360
|
+
// debug.ts
|
|
3361
|
+
init_define_import_meta_env();
|
|
3362
|
+
var lessPrecise = (num, precision = 5) => parseFloat(num.toPrecision(precision));
|
|
3363
|
+
var getAvgFrameTime = (times) => lessPrecise(times.reduce((a, b) => a + b) / times.length);
|
|
3364
|
+
var Debug = class _Debug {
|
|
3365
|
+
static DEBUG_LOG_TIMES = true;
|
|
3366
|
+
static TIMES_AGGR = {};
|
|
3367
|
+
static TIMES_AVG = {};
|
|
3368
|
+
static LAST_DEBUG_LOG_CALL = 0;
|
|
3369
|
+
static DEBUG_LOG_INTERVAL_ID = null;
|
|
3370
|
+
static LAST_FRAME_TIMESTAMP = 0;
|
|
3371
|
+
static FRAME_COUNT = 0;
|
|
3372
|
+
static ANIMATION_FRAME_ID = null;
|
|
3373
|
+
static scheduleAnimationFrame = () => {
|
|
3374
|
+
if (_Debug.DEBUG_LOG_INTERVAL_ID !== null) {
|
|
3375
|
+
_Debug.ANIMATION_FRAME_ID = requestAnimationFrame((timestamp) => {
|
|
3376
|
+
if (_Debug.LAST_FRAME_TIMESTAMP !== timestamp) {
|
|
3377
|
+
_Debug.LAST_FRAME_TIMESTAMP = timestamp;
|
|
3378
|
+
_Debug.FRAME_COUNT++;
|
|
3379
|
+
}
|
|
3380
|
+
if (_Debug.DEBUG_LOG_INTERVAL_ID !== null) {
|
|
3381
|
+
_Debug.scheduleAnimationFrame();
|
|
3382
|
+
}
|
|
3383
|
+
});
|
|
3384
|
+
}
|
|
3385
|
+
};
|
|
3386
|
+
static setupInterval = () => {
|
|
3387
|
+
if (_Debug.DEBUG_LOG_INTERVAL_ID === null) {
|
|
3388
|
+
console.info("%c(starting perf recording)", "color: lime");
|
|
3389
|
+
_Debug.DEBUG_LOG_INTERVAL_ID = window.setInterval(_Debug.debugLogger, 1e3);
|
|
3390
|
+
_Debug.scheduleAnimationFrame();
|
|
3391
|
+
}
|
|
3392
|
+
_Debug.LAST_DEBUG_LOG_CALL = Date.now();
|
|
3393
|
+
};
|
|
3394
|
+
static debugLogger = () => {
|
|
3395
|
+
if (_Debug.DEBUG_LOG_TIMES) {
|
|
3396
|
+
for (const [name, { t, times }] of Object.entries(_Debug.TIMES_AGGR)) {
|
|
3397
|
+
if (times.length) {
|
|
3398
|
+
console.info(
|
|
3399
|
+
name,
|
|
3400
|
+
lessPrecise(times.reduce((a, b) => a + b)),
|
|
3401
|
+
times.sort((a, b) => a - b).map((x) => lessPrecise(x))
|
|
3402
|
+
);
|
|
3403
|
+
_Debug.TIMES_AGGR[name] = { t, times: [] };
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
for (const [name, { t, times, avg }] of Object.entries(_Debug.TIMES_AVG)) {
|
|
3407
|
+
if (times.length) {
|
|
3408
|
+
const totalTime = times.reduce((a, b) => a + b);
|
|
3409
|
+
const avgFrameTime = lessPrecise(totalTime / _Debug.FRAME_COUNT);
|
|
3410
|
+
console.info(
|
|
3411
|
+
name,
|
|
3412
|
+
`- ${times.length} calls - ${avgFrameTime}ms/frame across ${_Debug.FRAME_COUNT} frames (${lessPrecise(
|
|
3413
|
+
avgFrameTime / 16.67 * 100,
|
|
3414
|
+
1
|
|
3415
|
+
)}% of frame budget)`
|
|
3416
|
+
);
|
|
3417
|
+
_Debug.TIMES_AVG[name] = {
|
|
3418
|
+
t,
|
|
3419
|
+
times: [],
|
|
3420
|
+
avg: avg != null ? getAvgFrameTime([avg, avgFrameTime]) : avgFrameTime
|
|
3421
|
+
};
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
_Debug.FRAME_COUNT = 0;
|
|
3426
|
+
if (Date.now() - _Debug.LAST_DEBUG_LOG_CALL > 600 && _Debug.DEBUG_LOG_INTERVAL_ID !== null) {
|
|
3427
|
+
console.info("%c(stopping perf recording)", "color: red");
|
|
3428
|
+
window.clearInterval(_Debug.DEBUG_LOG_INTERVAL_ID);
|
|
3429
|
+
window.cancelAnimationFrame(_Debug.ANIMATION_FRAME_ID);
|
|
3430
|
+
_Debug.ANIMATION_FRAME_ID = null;
|
|
3431
|
+
_Debug.FRAME_COUNT = 0;
|
|
3432
|
+
_Debug.LAST_FRAME_TIMESTAMP = 0;
|
|
3433
|
+
_Debug.DEBUG_LOG_INTERVAL_ID = null;
|
|
3434
|
+
_Debug.TIMES_AGGR = {};
|
|
3435
|
+
_Debug.TIMES_AVG = {};
|
|
3436
|
+
}
|
|
3437
|
+
};
|
|
3438
|
+
static logTime = (time, name = "default") => {
|
|
3439
|
+
_Debug.setupInterval();
|
|
3440
|
+
const now = performance.now();
|
|
3441
|
+
const { t, times } = _Debug.TIMES_AGGR[name] = _Debug.TIMES_AGGR[name] || {
|
|
3442
|
+
t: 0,
|
|
3443
|
+
times: []
|
|
3444
|
+
};
|
|
3445
|
+
if (t) {
|
|
3446
|
+
times.push(time != null ? time : now - t);
|
|
3447
|
+
}
|
|
3448
|
+
_Debug.TIMES_AGGR[name].t = now;
|
|
3449
|
+
};
|
|
3450
|
+
static logTimeAverage = (time, name = "default") => {
|
|
3451
|
+
_Debug.setupInterval();
|
|
3452
|
+
const now = performance.now();
|
|
3453
|
+
const { t, times } = _Debug.TIMES_AVG[name] = _Debug.TIMES_AVG[name] || {
|
|
3454
|
+
t: 0,
|
|
3455
|
+
times: []
|
|
3456
|
+
};
|
|
3457
|
+
if (t) {
|
|
3458
|
+
times.push(time != null ? time : now - t);
|
|
3459
|
+
}
|
|
3460
|
+
_Debug.TIMES_AVG[name].t = now;
|
|
3461
|
+
};
|
|
3462
|
+
static logWrapper = (type) => (fn, name = "default") => {
|
|
3463
|
+
return (...args) => {
|
|
3464
|
+
const t0 = performance.now();
|
|
3465
|
+
const ret = fn(...args);
|
|
3466
|
+
_Debug[type](performance.now() - t0, name);
|
|
3467
|
+
return ret;
|
|
3468
|
+
};
|
|
3469
|
+
};
|
|
3470
|
+
static logTimeWrap = _Debug.logWrapper("logTime");
|
|
3471
|
+
static logTimeAverageWrap = _Debug.logWrapper("logTimeAverage");
|
|
3472
|
+
static perfWrap = (fn, name = "default") => {
|
|
3473
|
+
return (...args) => {
|
|
3474
|
+
console.time(name);
|
|
3475
|
+
const ret = fn(...args);
|
|
3476
|
+
console.timeEnd(name);
|
|
3477
|
+
return ret;
|
|
3478
|
+
};
|
|
3479
|
+
};
|
|
3480
|
+
static CHANGED_CACHE = {};
|
|
3481
|
+
static logChanged(name, obj) {
|
|
3482
|
+
const prev = _Debug.CHANGED_CACHE[name];
|
|
3483
|
+
_Debug.CHANGED_CACHE[name] = obj;
|
|
3484
|
+
if (!prev) {
|
|
3485
|
+
return;
|
|
3486
|
+
}
|
|
3487
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(obj)]);
|
|
3488
|
+
const changed = {};
|
|
3489
|
+
for (const key of allKeys) {
|
|
3490
|
+
const prevVal = prev[key];
|
|
3491
|
+
const nextVal = obj[key];
|
|
3492
|
+
if (!deepEqual(prevVal, nextVal)) {
|
|
3493
|
+
changed[key] = { prev: prevVal, next: nextVal };
|
|
3494
|
+
}
|
|
3495
|
+
}
|
|
3496
|
+
if (Object.keys(changed).length > 0) {
|
|
3497
|
+
console.info(`[${name}] changed:`, changed);
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
};
|
|
3501
|
+
function deepEqual(a, b) {
|
|
3502
|
+
if (Object.is(a, b)) {
|
|
3503
|
+
return true;
|
|
3504
|
+
}
|
|
3505
|
+
if (a === null || b === null || typeof a !== "object" || typeof b !== "object") {
|
|
3506
|
+
return false;
|
|
3507
|
+
}
|
|
3508
|
+
if (Array.isArray(a) !== Array.isArray(b)) {
|
|
3509
|
+
return false;
|
|
3510
|
+
}
|
|
3511
|
+
const keysA = Object.keys(a);
|
|
3512
|
+
const keysB = Object.keys(b);
|
|
3513
|
+
if (keysA.length !== keysB.length) {
|
|
3514
|
+
return false;
|
|
3515
|
+
}
|
|
3516
|
+
for (const key of keysA) {
|
|
3517
|
+
if (!deepEqual(
|
|
3518
|
+
a[key],
|
|
3519
|
+
b[key]
|
|
3520
|
+
)) {
|
|
3521
|
+
return false;
|
|
3522
|
+
}
|
|
3523
|
+
}
|
|
3524
|
+
return true;
|
|
3525
|
+
}
|
|
3232
3526
|
export {
|
|
3233
3527
|
ACTIVE_THRESHOLD,
|
|
3234
3528
|
ALLOWED_PASTE_MIME_TYPES,
|
|
@@ -3236,6 +3530,7 @@ export {
|
|
|
3236
3530
|
ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO,
|
|
3237
3531
|
ARROW_LABEL_WIDTH_FRACTION,
|
|
3238
3532
|
ARROW_TYPE,
|
|
3533
|
+
AppEventBus,
|
|
3239
3534
|
BIND_MODE_TIMEOUT,
|
|
3240
3535
|
BOUND_TEXT_PADDING,
|
|
3241
3536
|
BinaryHeap,
|
|
@@ -3251,6 +3546,7 @@ export {
|
|
|
3251
3546
|
COLOR_VOICE_CALL,
|
|
3252
3547
|
COLOR_WHITE,
|
|
3253
3548
|
CURSOR_TYPE,
|
|
3549
|
+
DARK_THEME_FILTER,
|
|
3254
3550
|
DEFAULT_ADAPTIVE_RADIUS,
|
|
3255
3551
|
DEFAULT_CANVAS_BACKGROUND_PICKS,
|
|
3256
3552
|
DEFAULT_CHART_COLOR_INDEX,
|
|
@@ -3268,8 +3564,8 @@ export {
|
|
|
3268
3564
|
DEFAULT_FONT_SIZE,
|
|
3269
3565
|
DEFAULT_GRID_SIZE,
|
|
3270
3566
|
DEFAULT_GRID_STEP,
|
|
3567
|
+
DEFAULT_IMAGE_OPTIONS,
|
|
3271
3568
|
DEFAULT_LASER_COLOR,
|
|
3272
|
-
DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT,
|
|
3273
3569
|
DEFAULT_PROPORTIONAL_RADIUS,
|
|
3274
3570
|
DEFAULT_REDUCED_GLOBAL_ALPHA,
|
|
3275
3571
|
DEFAULT_SIDEBAR,
|
|
@@ -3280,6 +3576,7 @@ export {
|
|
|
3280
3576
|
DEFAULT_VERTICAL_ALIGN,
|
|
3281
3577
|
DOUBLE_TAP_POSITION_THRESHOLD,
|
|
3282
3578
|
DRAGGING_THRESHOLD,
|
|
3579
|
+
Debug,
|
|
3283
3580
|
EDITOR_LS_KEYS,
|
|
3284
3581
|
ELEMENT_LINK_KEY,
|
|
3285
3582
|
ELEMENT_READY_TO_ERASE_OPACITY,
|
|
@@ -3311,7 +3608,6 @@ export {
|
|
|
3311
3608
|
LINE_CONFIRM_THRESHOLD,
|
|
3312
3609
|
LINE_POLYGON_POINT_MERGE_DISTANCE,
|
|
3313
3610
|
LOCAL_FONT_PROTOCOL,
|
|
3314
|
-
MAX_ALLOWED_FILE_BYTES,
|
|
3315
3611
|
MAX_CUSTOM_COLORS_USED_IN_CANVAS,
|
|
3316
3612
|
MAX_DECIMALS_FOR_SVG_EXPORT,
|
|
3317
3613
|
MAX_ZOOM,
|
|
@@ -3359,6 +3655,7 @@ export {
|
|
|
3359
3655
|
VERSIONS,
|
|
3360
3656
|
VERSION_TIMEOUT,
|
|
3361
3657
|
VERTICAL_ALIGN,
|
|
3658
|
+
VersionedSnapshotStore,
|
|
3362
3659
|
WINDOWS_EMOJI_FALLBACK_FONT,
|
|
3363
3660
|
YOUTUBE_STATES,
|
|
3364
3661
|
ZOOM_STEP,
|
|
@@ -3452,6 +3749,7 @@ export {
|
|
|
3452
3749
|
normalizeEOL,
|
|
3453
3750
|
normalizeInputColor,
|
|
3454
3751
|
normalizeLink,
|
|
3752
|
+
oneOf,
|
|
3455
3753
|
preventUnload,
|
|
3456
3754
|
promiseTry,
|
|
3457
3755
|
queryFocusableElements,
|