@excalidraw/common 0.18.0-9ba0f5d → 0.18.0-a9ca16e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/dev/index.js +315 -21
  2. package/dist/dev/index.js.map +3 -3
  3. package/dist/prod/index.js +3 -3
  4. package/dist/types/common/debug.d.ts +21 -0
  5. package/dist/types/common/src/appEventBus.d.ts +27 -0
  6. package/dist/types/common/src/colors.d.ts +13 -13
  7. package/dist/types/common/src/constants.d.ts +4 -0
  8. package/dist/types/common/src/index.d.ts +3 -0
  9. package/dist/types/common/src/utils.d.ts +4 -7
  10. package/dist/types/common/src/versionedSnapshotStore.d.ts +17 -0
  11. package/dist/types/element/src/Scene.d.ts +2 -0
  12. package/dist/types/element/src/arrowheads.d.ts +3 -0
  13. package/dist/types/element/src/arrows/focus.d.ts +27 -0
  14. package/dist/types/element/src/arrows/helpers.d.ts +5 -0
  15. package/dist/types/element/src/binding.d.ts +13 -8
  16. package/dist/types/element/src/bounds.d.ts +1 -1
  17. package/dist/types/element/src/collision.d.ts +4 -3
  18. package/dist/types/element/src/distribute.d.ts +2 -1
  19. package/dist/types/element/src/elbowArrow.d.ts +2 -0
  20. package/dist/types/element/src/index.d.ts +3 -0
  21. package/dist/types/element/src/linearElementEditor.d.ts +5 -0
  22. package/dist/types/element/src/mutateElement.d.ts +2 -0
  23. package/dist/types/element/src/selection.d.ts +6 -2
  24. package/dist/types/element/src/textElement.d.ts +1 -1
  25. package/dist/types/element/src/textWrapping.d.ts +26 -0
  26. package/dist/types/element/src/types.d.ts +5 -2
  27. package/dist/types/element/src/utils.d.ts +5 -3
  28. package/dist/types/element/src/zindex.d.ts +1 -1
  29. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +38 -35
  30. package/dist/types/excalidraw/actions/actionBoundText.d.ts +27 -25
  31. package/dist/types/excalidraw/actions/actionCanvas.d.ts +216 -204
  32. package/dist/types/excalidraw/actions/actionClipboard.d.ts +26 -24
  33. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +13 -12
  34. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +42 -37
  35. package/dist/types/excalidraw/actions/actionElementLink.d.ts +9 -12
  36. package/dist/types/excalidraw/actions/actionElementLock.d.ts +26 -24
  37. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +13 -12
  38. package/dist/types/excalidraw/actions/actionExport.d.ts +114 -386
  39. package/dist/types/excalidraw/actions/actionFrame.d.ts +52 -48
  40. package/dist/types/excalidraw/actions/actionGroup.d.ts +29 -27
  41. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +15 -12
  42. package/dist/types/excalidraw/actions/actionLink.d.ts +13 -12
  43. package/dist/types/excalidraw/actions/actionMenu.d.ts +9 -12
  44. package/dist/types/excalidraw/actions/actionProperties.d.ts +29 -27
  45. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +14 -13
  46. package/dist/types/excalidraw/actions/actionStyles.d.ts +13 -11
  47. package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
  48. package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +172 -0
  49. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +13 -12
  50. package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +172 -0
  51. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +13 -12
  52. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +9 -12
  53. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +13 -12
  54. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +13 -12
  55. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +13 -12
  56. package/dist/types/excalidraw/actions/index.d.ts +2 -0
  57. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -1
  58. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  59. package/dist/types/excalidraw/appState.d.ts +29 -27
  60. package/dist/types/excalidraw/charts/charts.bar.d.ts +2 -0
  61. package/dist/types/excalidraw/charts/charts.constants.d.ts +48 -0
  62. package/dist/types/excalidraw/charts/charts.helpers.d.ts +32 -0
  63. package/dist/types/excalidraw/charts/charts.line.d.ts +2 -0
  64. package/dist/types/excalidraw/charts/charts.parse.d.ts +10 -0
  65. package/dist/types/excalidraw/charts/charts.radar.d.ts +2 -0
  66. package/dist/types/excalidraw/charts/charts.types.d.ts +18 -0
  67. package/dist/types/excalidraw/charts/index.d.ts +7 -0
  68. package/dist/types/excalidraw/clipboard.d.ts +8 -9
  69. package/dist/types/excalidraw/components/App.d.ts +53 -13
  70. package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
  71. package/dist/types/excalidraw/components/CommandPalette/types.d.ts +1 -1
  72. package/dist/types/excalidraw/components/IconPicker.d.ts +14 -9
  73. package/dist/types/excalidraw/components/PasteChartDialog.d.ts +4 -5
  74. package/dist/types/excalidraw/components/PropertiesPopover.d.ts +1 -1
  75. package/dist/types/excalidraw/components/Range.d.ts +10 -4
  76. package/dist/types/excalidraw/components/TTDDialog/Chat/ChatInterface.d.ts +2 -6
  77. package/dist/types/excalidraw/components/TTDDialog/Chat/TTDChatPanel.d.ts +2 -1
  78. package/dist/types/excalidraw/components/TTDDialog/CodeMirrorEditor.d.ts +11 -0
  79. package/dist/types/excalidraw/components/TTDDialog/TTDDialog.d.ts +11 -7
  80. package/dist/types/excalidraw/components/TTDDialog/TTDDialogInput.d.ts +3 -3
  81. package/dist/types/excalidraw/components/TTDDialog/TTDDialogOutput.d.ts +4 -1
  82. package/dist/types/excalidraw/components/TTDDialog/TTDWelcomeMessage.d.ts +1 -0
  83. package/dist/types/excalidraw/components/TTDDialog/TextToDiagram.d.ts +2 -1
  84. package/dist/types/excalidraw/components/TTDDialog/mermaid-lang-lite.d.ts +2 -0
  85. package/dist/types/excalidraw/components/TTDDialog/types.d.ts +4 -0
  86. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidAutoFix.d.ts +1 -0
  87. package/dist/types/excalidraw/components/TTDDialog/utils/mermaidError.d.ts +10 -0
  88. package/dist/types/excalidraw/components/Toast.d.ts +8 -4
  89. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
  90. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenu.d.ts +30 -16
  91. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuContent.d.ts +3 -2
  92. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItem.d.ts +11 -12
  93. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemCheckbox.d.ts +5 -0
  94. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuItemContent.d.ts +2 -1
  95. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSub.d.ts +23 -0
  96. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubContent.d.ts +8 -0
  97. package/dist/types/excalidraw/components/dropdownMenu/DropdownMenuSubTrigger.d.ts +12 -0
  98. package/dist/types/excalidraw/components/dropdownMenu/common.d.ts +1 -1
  99. package/dist/types/excalidraw/components/dropdownMenu/dropdownMenuUtils.d.ts +2 -0
  100. package/dist/types/excalidraw/components/icons.d.ts +23 -9
  101. package/dist/types/excalidraw/components/main-menu/DefaultItems.d.ts +17 -0
  102. package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +23 -14
  103. package/dist/types/excalidraw/components/shapes.d.ts +74 -1
  104. package/dist/types/excalidraw/data/blob.d.ts +167 -166
  105. package/dist/types/excalidraw/data/filesystem.d.ts +3 -5
  106. package/dist/types/excalidraw/data/index.d.ts +2 -3
  107. package/dist/types/excalidraw/data/json.d.ts +94 -85
  108. package/dist/types/excalidraw/data/resave.d.ts +7 -2
  109. package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
  110. package/dist/types/excalidraw/types.d.ts +93 -16
  111. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +5 -1
  112. package/dist/types/math/src/point.d.ts +7 -2
  113. package/dist/types/math/src/types.d.ts +25 -1
  114. package/package.json +1 -1
  115. package/dist/types/excalidraw/charts.d.ts +0 -27
  116. package/dist/types/excalidraw/components/DiagramToCodePlugin/DiagramToCodePlugin.d.ts +0 -4
  117. package/dist/types/excalidraw/components/ExcalidrawLogo.d.ts +0 -15
  118. package/dist/types/excalidraw/components/InitializeApp.d.ts +0 -10
  119. package/dist/types/excalidraw/components/TTDDialog/TTDDialogTrigger.d.ts +0 -8
  120. package/dist/types/excalidraw/components/TTDDialog/utils/TTDStreamFetch.d.ts +0 -24
  121. package/dist/types/excalidraw/components/footer/FooterCenter.d.ts +0 -8
  122. package/dist/types/excalidraw/components/live-collaboration/LiveCollaborationTrigger.d.ts +0 -11
  123. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Center.d.ts +0 -58
  124. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.Hints.d.ts +0 -19
  125. package/dist/types/excalidraw/components/welcome-screen/WelcomeScreen.d.ts +0 -84
  126. package/dist/types/excalidraw/data/reconcile.d.ts +0 -7
  127. package/dist/types/excalidraw/index.d.ts +0 -46
  128. package/dist/types/excalidraw/polyfill.d.ts +0 -2
package/dist/dev/index.js CHANGED
@@ -1562,7 +1562,7 @@ var normalizeInputColor = (color) => {
1562
1562
  }
1563
1563
  const tc = tinycolor(color);
1564
1564
  if (tc.isValid()) {
1565
- if (tc.getFormat() === "hex" && !color.startsWith("#")) {
1565
+ if (["hex", "hex8"].includes(tc.getFormat()) && !color.startsWith("#")) {
1566
1566
  return `#${color}`;
1567
1567
  }
1568
1568
  return color;
@@ -1659,7 +1659,8 @@ var CLASSES = {
1659
1659
  SEARCH_MENU_INPUT_WRAPPER: "layer-ui__search-inputWrapper",
1660
1660
  CONVERT_ELEMENT_TYPE_POPUP: "ConvertElementTypePopup",
1661
1661
  SHAPE_ACTIONS_THEME_SCOPE: "shape-actions-theme-scope",
1662
- FRAME_NAME: "frame-name"
1662
+ FRAME_NAME: "frame-name",
1663
+ DROPDOWN_MENU_EVENT_WRAPPER: "dropdown-menu-event-wrapper"
1663
1664
  };
1664
1665
  var FONT_SIZES = {
1665
1666
  sm: 16,
@@ -1718,6 +1719,7 @@ var THEME = {
1718
1719
  LIGHT: "light",
1719
1720
  DARK: "dark"
1720
1721
  };
1722
+ var DARK_THEME_FILTER = "invert(93%) hue-rotate(180deg)";
1721
1723
  var FRAME_STYLE = {
1722
1724
  strokeColor: "#bbb",
1723
1725
  strokeWidth: 2,
@@ -1766,6 +1768,7 @@ var STRING_MIME_TYPES = {
1766
1768
  json: "application/json",
1767
1769
  // excalidraw data
1768
1770
  excalidraw: "application/vnd.excalidraw+json",
1771
+ excalidrawClipboard: "application/vnd.excalidraw.clipboard+json",
1769
1772
  // LEGACY: fully-qualified library JSON data
1770
1773
  excalidrawlib: "application/vnd.excalidrawlib+json",
1771
1774
  // list of excalidraw library item ids
@@ -2481,7 +2484,7 @@ var isInteractive = (target) => {
2481
2484
  return isInputLike(target) || target instanceof Element && !!target.closest("label, button");
2482
2485
  };
2483
2486
  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");
2487
+ 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
2488
  var getFontFamilyString = ({
2486
2489
  fontFamily
2487
2490
  }) => {
@@ -2526,32 +2529,23 @@ var debounce = (fn, timeout) => {
2526
2529
  };
2527
2530
  return ret;
2528
2531
  };
2529
- var throttleRAF = (fn, opts) => {
2532
+ var throttleRAF = (fn) => {
2530
2533
  let timerId = null;
2531
2534
  let lastArgs = null;
2532
- let lastArgsTrailing = null;
2533
- const scheduleFunc = (args) => {
2535
+ const scheduleFunc = () => {
2534
2536
  timerId = window.requestAnimationFrame(() => {
2535
2537
  timerId = null;
2536
- fn(...args);
2538
+ const args = lastArgs;
2537
2539
  lastArgs = null;
2538
- if (lastArgsTrailing) {
2539
- lastArgs = lastArgsTrailing;
2540
- lastArgsTrailing = null;
2541
- scheduleFunc(lastArgs);
2540
+ if (args) {
2541
+ fn(...args);
2542
2542
  }
2543
2543
  });
2544
2544
  };
2545
2545
  const ret = (...args) => {
2546
- if (isTestEnv()) {
2547
- fn(...args);
2548
- return;
2549
- }
2550
2546
  lastArgs = args;
2551
2547
  if (timerId === null) {
2552
- scheduleFunc(lastArgs);
2553
- } else if (opts?.trailing) {
2554
- lastArgsTrailing = args;
2548
+ scheduleFunc();
2555
2549
  }
2556
2550
  };
2557
2551
  ret.flush = () => {
@@ -2560,12 +2554,12 @@ var throttleRAF = (fn, opts) => {
2560
2554
  timerId = null;
2561
2555
  }
2562
2556
  if (lastArgs) {
2563
- fn(...lastArgsTrailing || lastArgs);
2564
- lastArgs = lastArgsTrailing = null;
2557
+ fn(...lastArgs);
2558
+ lastArgs = null;
2565
2559
  }
2566
2560
  };
2567
2561
  ret.cancel = () => {
2568
- lastArgs = lastArgsTrailing = null;
2562
+ lastArgs = null;
2569
2563
  if (timerId !== null) {
2570
2564
  cancelAnimationFrame(timerId);
2571
2565
  timerId = null;
@@ -3156,6 +3150,9 @@ var setFeatureFlag = (flag, value) => {
3156
3150
  console.error("unable to set feature flag", e);
3157
3151
  }
3158
3152
  };
3153
+ var oneOf = (needle, haystack) => {
3154
+ return haystack.includes(needle);
3155
+ };
3159
3156
 
3160
3157
  // src/random.ts
3161
3158
  var random = new Random(Date.now());
@@ -3229,6 +3226,298 @@ var Emitter = class {
3229
3226
  this.subscribers = [];
3230
3227
  }
3231
3228
  };
3229
+
3230
+ // src/appEventBus.ts
3231
+ init_define_import_meta_env();
3232
+ var AppEventBus = class {
3233
+ constructor(behavior) {
3234
+ this.behavior = behavior;
3235
+ }
3236
+ emitters = /* @__PURE__ */ new Map();
3237
+ lastPayload = /* @__PURE__ */ new Map();
3238
+ emittedOnce = /* @__PURE__ */ new Set();
3239
+ getEmitter(name) {
3240
+ let emitter = this.emitters.get(name);
3241
+ if (!emitter) {
3242
+ emitter = new Emitter();
3243
+ this.emitters.set(name, emitter);
3244
+ }
3245
+ return emitter;
3246
+ }
3247
+ toPromiseValue(args) {
3248
+ return args.length === 1 ? args[0] : args;
3249
+ }
3250
+ on(name, callback) {
3251
+ const eventBehavior = this.behavior[name];
3252
+ const cachedPayload = this.lastPayload.get(name);
3253
+ if (callback) {
3254
+ if (eventBehavior.replay === "last" && cachedPayload) {
3255
+ queueMicrotask(() => callback(...cachedPayload));
3256
+ if (eventBehavior.cardinality === "once") {
3257
+ return () => {
3258
+ };
3259
+ }
3260
+ }
3261
+ return this.getEmitter(name).on(callback);
3262
+ }
3263
+ if (eventBehavior.cardinality !== "once" || eventBehavior.replay !== "last") {
3264
+ throw new Error(`Event "${String(name)}" requires a callback`);
3265
+ }
3266
+ if (cachedPayload) {
3267
+ return Promise.resolve(this.toPromiseValue(cachedPayload));
3268
+ }
3269
+ return new Promise((resolve) => {
3270
+ this.getEmitter(name).once((...args) => {
3271
+ resolve(this.toPromiseValue(args));
3272
+ });
3273
+ });
3274
+ }
3275
+ emit(name, ...args) {
3276
+ const eventBehavior = this.behavior[name];
3277
+ if (!isProdEnv()) {
3278
+ if (eventBehavior.cardinality === "once") {
3279
+ if (this.emittedOnce.has(name)) {
3280
+ throw new Error(`Event "${String(name)}" can only be emitted once`);
3281
+ }
3282
+ this.emittedOnce.add(name);
3283
+ }
3284
+ }
3285
+ if (eventBehavior.replay === "last") {
3286
+ this.lastPayload.set(name, args);
3287
+ }
3288
+ try {
3289
+ this.getEmitter(name).trigger(...args);
3290
+ } finally {
3291
+ if (eventBehavior.cardinality === "once") {
3292
+ this.getEmitter(name).clear();
3293
+ }
3294
+ }
3295
+ }
3296
+ clear() {
3297
+ this.lastPayload.clear();
3298
+ this.emittedOnce.clear();
3299
+ for (const emitter of this.emitters.values()) {
3300
+ emitter.clear();
3301
+ }
3302
+ this.emitters.clear();
3303
+ }
3304
+ };
3305
+
3306
+ // src/versionedSnapshotStore.ts
3307
+ init_define_import_meta_env();
3308
+ var VersionedSnapshotStore = class {
3309
+ constructor(initialValue, isEqual = Object.is) {
3310
+ this.isEqual = isEqual;
3311
+ this.value = initialValue;
3312
+ }
3313
+ version = 0;
3314
+ value;
3315
+ waiters = /* @__PURE__ */ new Set();
3316
+ subscribers = /* @__PURE__ */ new Set();
3317
+ getSnapshot() {
3318
+ return { version: this.version, value: this.value };
3319
+ }
3320
+ set(nextValue) {
3321
+ if (this.isEqual(this.value, nextValue)) {
3322
+ return false;
3323
+ }
3324
+ this.value = nextValue;
3325
+ this.version += 1;
3326
+ const snapshot = this.getSnapshot();
3327
+ for (const subscriber of this.subscribers) {
3328
+ subscriber(snapshot);
3329
+ }
3330
+ for (const waiter of this.waiters) {
3331
+ waiter(snapshot);
3332
+ }
3333
+ this.waiters.clear();
3334
+ return true;
3335
+ }
3336
+ update(updater) {
3337
+ return this.set(updater(this.value));
3338
+ }
3339
+ subscribe(subscriber) {
3340
+ this.subscribers.add(subscriber);
3341
+ return () => {
3342
+ this.subscribers.delete(subscriber);
3343
+ };
3344
+ }
3345
+ pull(sinceVersion = -1) {
3346
+ if (this.version !== sinceVersion) {
3347
+ return Promise.resolve(this.getSnapshot());
3348
+ }
3349
+ return new Promise((resolve) => {
3350
+ this.waiters.add(resolve);
3351
+ });
3352
+ }
3353
+ };
3354
+
3355
+ // debug.ts
3356
+ init_define_import_meta_env();
3357
+ var lessPrecise = (num, precision = 5) => parseFloat(num.toPrecision(precision));
3358
+ var getAvgFrameTime = (times) => lessPrecise(times.reduce((a, b) => a + b) / times.length);
3359
+ var Debug = class _Debug {
3360
+ static DEBUG_LOG_TIMES = true;
3361
+ static TIMES_AGGR = {};
3362
+ static TIMES_AVG = {};
3363
+ static LAST_DEBUG_LOG_CALL = 0;
3364
+ static DEBUG_LOG_INTERVAL_ID = null;
3365
+ static LAST_FRAME_TIMESTAMP = 0;
3366
+ static FRAME_COUNT = 0;
3367
+ static ANIMATION_FRAME_ID = null;
3368
+ static scheduleAnimationFrame = () => {
3369
+ if (_Debug.DEBUG_LOG_INTERVAL_ID !== null) {
3370
+ _Debug.ANIMATION_FRAME_ID = requestAnimationFrame((timestamp) => {
3371
+ if (_Debug.LAST_FRAME_TIMESTAMP !== timestamp) {
3372
+ _Debug.LAST_FRAME_TIMESTAMP = timestamp;
3373
+ _Debug.FRAME_COUNT++;
3374
+ }
3375
+ if (_Debug.DEBUG_LOG_INTERVAL_ID !== null) {
3376
+ _Debug.scheduleAnimationFrame();
3377
+ }
3378
+ });
3379
+ }
3380
+ };
3381
+ static setupInterval = () => {
3382
+ if (_Debug.DEBUG_LOG_INTERVAL_ID === null) {
3383
+ console.info("%c(starting perf recording)", "color: lime");
3384
+ _Debug.DEBUG_LOG_INTERVAL_ID = window.setInterval(_Debug.debugLogger, 1e3);
3385
+ _Debug.scheduleAnimationFrame();
3386
+ }
3387
+ _Debug.LAST_DEBUG_LOG_CALL = Date.now();
3388
+ };
3389
+ static debugLogger = () => {
3390
+ if (_Debug.DEBUG_LOG_TIMES) {
3391
+ for (const [name, { t, times }] of Object.entries(_Debug.TIMES_AGGR)) {
3392
+ if (times.length) {
3393
+ console.info(
3394
+ name,
3395
+ lessPrecise(times.reduce((a, b) => a + b)),
3396
+ times.sort((a, b) => a - b).map((x) => lessPrecise(x))
3397
+ );
3398
+ _Debug.TIMES_AGGR[name] = { t, times: [] };
3399
+ }
3400
+ }
3401
+ for (const [name, { t, times, avg }] of Object.entries(_Debug.TIMES_AVG)) {
3402
+ if (times.length) {
3403
+ const totalTime = times.reduce((a, b) => a + b);
3404
+ const avgFrameTime = lessPrecise(totalTime / _Debug.FRAME_COUNT);
3405
+ console.info(
3406
+ name,
3407
+ `- ${times.length} calls - ${avgFrameTime}ms/frame across ${_Debug.FRAME_COUNT} frames (${lessPrecise(
3408
+ avgFrameTime / 16.67 * 100,
3409
+ 1
3410
+ )}% of frame budget)`
3411
+ );
3412
+ _Debug.TIMES_AVG[name] = {
3413
+ t,
3414
+ times: [],
3415
+ avg: avg != null ? getAvgFrameTime([avg, avgFrameTime]) : avgFrameTime
3416
+ };
3417
+ }
3418
+ }
3419
+ }
3420
+ _Debug.FRAME_COUNT = 0;
3421
+ if (Date.now() - _Debug.LAST_DEBUG_LOG_CALL > 600 && _Debug.DEBUG_LOG_INTERVAL_ID !== null) {
3422
+ console.info("%c(stopping perf recording)", "color: red");
3423
+ window.clearInterval(_Debug.DEBUG_LOG_INTERVAL_ID);
3424
+ window.cancelAnimationFrame(_Debug.ANIMATION_FRAME_ID);
3425
+ _Debug.ANIMATION_FRAME_ID = null;
3426
+ _Debug.FRAME_COUNT = 0;
3427
+ _Debug.LAST_FRAME_TIMESTAMP = 0;
3428
+ _Debug.DEBUG_LOG_INTERVAL_ID = null;
3429
+ _Debug.TIMES_AGGR = {};
3430
+ _Debug.TIMES_AVG = {};
3431
+ }
3432
+ };
3433
+ static logTime = (time, name = "default") => {
3434
+ _Debug.setupInterval();
3435
+ const now = performance.now();
3436
+ const { t, times } = _Debug.TIMES_AGGR[name] = _Debug.TIMES_AGGR[name] || {
3437
+ t: 0,
3438
+ times: []
3439
+ };
3440
+ if (t) {
3441
+ times.push(time != null ? time : now - t);
3442
+ }
3443
+ _Debug.TIMES_AGGR[name].t = now;
3444
+ };
3445
+ static logTimeAverage = (time, name = "default") => {
3446
+ _Debug.setupInterval();
3447
+ const now = performance.now();
3448
+ const { t, times } = _Debug.TIMES_AVG[name] = _Debug.TIMES_AVG[name] || {
3449
+ t: 0,
3450
+ times: []
3451
+ };
3452
+ if (t) {
3453
+ times.push(time != null ? time : now - t);
3454
+ }
3455
+ _Debug.TIMES_AVG[name].t = now;
3456
+ };
3457
+ static logWrapper = (type) => (fn, name = "default") => {
3458
+ return (...args) => {
3459
+ const t0 = performance.now();
3460
+ const ret = fn(...args);
3461
+ _Debug[type](performance.now() - t0, name);
3462
+ return ret;
3463
+ };
3464
+ };
3465
+ static logTimeWrap = _Debug.logWrapper("logTime");
3466
+ static logTimeAverageWrap = _Debug.logWrapper("logTimeAverage");
3467
+ static perfWrap = (fn, name = "default") => {
3468
+ return (...args) => {
3469
+ console.time(name);
3470
+ const ret = fn(...args);
3471
+ console.timeEnd(name);
3472
+ return ret;
3473
+ };
3474
+ };
3475
+ static CHANGED_CACHE = {};
3476
+ static logChanged(name, obj) {
3477
+ const prev = _Debug.CHANGED_CACHE[name];
3478
+ _Debug.CHANGED_CACHE[name] = obj;
3479
+ if (!prev) {
3480
+ return;
3481
+ }
3482
+ const allKeys = /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(obj)]);
3483
+ const changed = {};
3484
+ for (const key of allKeys) {
3485
+ const prevVal = prev[key];
3486
+ const nextVal = obj[key];
3487
+ if (!deepEqual(prevVal, nextVal)) {
3488
+ changed[key] = { prev: prevVal, next: nextVal };
3489
+ }
3490
+ }
3491
+ if (Object.keys(changed).length > 0) {
3492
+ console.info(`[${name}] changed:`, changed);
3493
+ }
3494
+ }
3495
+ };
3496
+ function deepEqual(a, b) {
3497
+ if (Object.is(a, b)) {
3498
+ return true;
3499
+ }
3500
+ if (a === null || b === null || typeof a !== "object" || typeof b !== "object") {
3501
+ return false;
3502
+ }
3503
+ if (Array.isArray(a) !== Array.isArray(b)) {
3504
+ return false;
3505
+ }
3506
+ const keysA = Object.keys(a);
3507
+ const keysB = Object.keys(b);
3508
+ if (keysA.length !== keysB.length) {
3509
+ return false;
3510
+ }
3511
+ for (const key of keysA) {
3512
+ if (!deepEqual(
3513
+ a[key],
3514
+ b[key]
3515
+ )) {
3516
+ return false;
3517
+ }
3518
+ }
3519
+ return true;
3520
+ }
3232
3521
  export {
3233
3522
  ACTIVE_THRESHOLD,
3234
3523
  ALLOWED_PASTE_MIME_TYPES,
@@ -3236,6 +3525,7 @@ export {
3236
3525
  ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO,
3237
3526
  ARROW_LABEL_WIDTH_FRACTION,
3238
3527
  ARROW_TYPE,
3528
+ AppEventBus,
3239
3529
  BIND_MODE_TIMEOUT,
3240
3530
  BOUND_TEXT_PADDING,
3241
3531
  BinaryHeap,
@@ -3251,6 +3541,7 @@ export {
3251
3541
  COLOR_VOICE_CALL,
3252
3542
  COLOR_WHITE,
3253
3543
  CURSOR_TYPE,
3544
+ DARK_THEME_FILTER,
3254
3545
  DEFAULT_ADAPTIVE_RADIUS,
3255
3546
  DEFAULT_CANVAS_BACKGROUND_PICKS,
3256
3547
  DEFAULT_CHART_COLOR_INDEX,
@@ -3280,6 +3571,7 @@ export {
3280
3571
  DEFAULT_VERTICAL_ALIGN,
3281
3572
  DOUBLE_TAP_POSITION_THRESHOLD,
3282
3573
  DRAGGING_THRESHOLD,
3574
+ Debug,
3283
3575
  EDITOR_LS_KEYS,
3284
3576
  ELEMENT_LINK_KEY,
3285
3577
  ELEMENT_READY_TO_ERASE_OPACITY,
@@ -3359,6 +3651,7 @@ export {
3359
3651
  VERSIONS,
3360
3652
  VERSION_TIMEOUT,
3361
3653
  VERTICAL_ALIGN,
3654
+ VersionedSnapshotStore,
3362
3655
  WINDOWS_EMOJI_FALLBACK_FONT,
3363
3656
  YOUTUBE_STATES,
3364
3657
  ZOOM_STEP,
@@ -3452,6 +3745,7 @@ export {
3452
3745
  normalizeEOL,
3453
3746
  normalizeInputColor,
3454
3747
  normalizeLink,
3748
+ oneOf,
3455
3749
  preventUnload,
3456
3750
  promiseTry,
3457
3751
  queryFocusableElements,