@myoc/common 0.19.502-d9d5eeb32 → 0.19.503
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 +313 -21
- 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 +13 -13
- package/dist/types/common/src/constants.d.ts +3 -0
- 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 +2 -0
- 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 +1 -1
- 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/elbowArrow.d.ts +2 -0
- package/dist/types/element/src/index.d.ts +3 -0
- package/dist/types/element/src/linearElementEditor.d.ts +5 -0
- package/dist/types/element/src/mutateElement.d.ts +2 -0
- package/dist/types/element/src/selection.d.ts +6 -2
- 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/types.d.ts +5 -2
- package/dist/types/element/src/utils.d.ts +5 -3
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +38 -35
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +27 -25
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +143 -132
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +26 -24
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +13 -12
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +42 -37
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +9 -12
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +26 -24
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +13 -12
- package/dist/types/excalidraw/actions/actionExport.d.ts +112 -405
- package/dist/types/excalidraw/actions/actionFrame.d.ts +52 -48
- package/dist/types/excalidraw/actions/actionGroup.d.ts +29 -27
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +15 -12
- package/dist/types/excalidraw/actions/actionLink.d.ts +13 -12
- package/dist/types/excalidraw/actions/actionMenu.d.ts +9 -12
- package/dist/types/excalidraw/actions/actionProperties.d.ts +29 -27
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +14 -13
- package/dist/types/excalidraw/actions/actionStyles.d.ts +13 -11
- package/dist/types/excalidraw/actions/actionTextAutoResize.d.ts +3 -3
- package/dist/types/excalidraw/actions/actionToggleArrowBinding.d.ts +181 -0
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +13 -12
- package/dist/types/excalidraw/actions/actionToggleMidpointSnapping.d.ts +181 -0
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +13 -12
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +9 -12
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +13 -12
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +13 -12
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +13 -12
- package/dist/types/excalidraw/actions/index.d.ts +2 -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/appState.d.ts +34 -32
- 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 +55 -13
- package/dist/types/excalidraw/components/AppStateObserver.d.ts +37 -0
- 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/Toast.d.ts +8 -4
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
- 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/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 +17 -0
- package/dist/types/excalidraw/components/main-menu/MainMenu.d.ts +23 -13
- package/dist/types/excalidraw/data/blob.d.ts +163 -162
- 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 +92 -83
- package/dist/types/excalidraw/data/resave.d.ts +7 -2
- package/dist/types/excalidraw/hooks/useAppStateValue.d.ts +29 -0
- package/dist/types/excalidraw/index.d.ts +25 -3
- package/dist/types/excalidraw/textAutoResizeHandle.d.ts +15 -0
- package/dist/types/excalidraw/types.d.ts +93 -16
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +5 -1
- package/dist/types/math/src/point.d.ts +7 -2
- package/dist/types/math/src/types.d.ts +25 -1
- package/package.json +1 -1
- package/dist/types/excalidraw/charts.d.ts +0 -27
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()
|
|
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,
|
|
@@ -1767,6 +1768,7 @@ var STRING_MIME_TYPES = {
|
|
|
1767
1768
|
json: "application/json",
|
|
1768
1769
|
// excalidraw data
|
|
1769
1770
|
excalidraw: "application/vnd.excalidraw+json",
|
|
1771
|
+
excalidrawClipboard: "application/vnd.excalidraw.clipboard+json",
|
|
1770
1772
|
// LEGACY: fully-qualified library JSON data
|
|
1771
1773
|
excalidrawlib: "application/vnd.excalidrawlib+json",
|
|
1772
1774
|
// list of excalidraw library item ids
|
|
@@ -2481,7 +2483,7 @@ var isInteractive = (target) => {
|
|
|
2481
2483
|
return isInputLike(target) || target instanceof Element && !!target.closest("label, button");
|
|
2482
2484
|
};
|
|
2483
2485
|
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");
|
|
2486
|
+
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
2487
|
var getFontFamilyString = ({
|
|
2486
2488
|
fontFamily
|
|
2487
2489
|
}) => {
|
|
@@ -2526,32 +2528,23 @@ var debounce = (fn, timeout) => {
|
|
|
2526
2528
|
};
|
|
2527
2529
|
return ret;
|
|
2528
2530
|
};
|
|
2529
|
-
var throttleRAF = (fn
|
|
2531
|
+
var throttleRAF = (fn) => {
|
|
2530
2532
|
let timerId = null;
|
|
2531
2533
|
let lastArgs = null;
|
|
2532
|
-
|
|
2533
|
-
const scheduleFunc = (args) => {
|
|
2534
|
+
const scheduleFunc = () => {
|
|
2534
2535
|
timerId = window.requestAnimationFrame(() => {
|
|
2535
2536
|
timerId = null;
|
|
2536
|
-
|
|
2537
|
+
const args = lastArgs;
|
|
2537
2538
|
lastArgs = null;
|
|
2538
|
-
if (
|
|
2539
|
-
|
|
2540
|
-
lastArgsTrailing = null;
|
|
2541
|
-
scheduleFunc(lastArgs);
|
|
2539
|
+
if (args) {
|
|
2540
|
+
fn(...args);
|
|
2542
2541
|
}
|
|
2543
2542
|
});
|
|
2544
2543
|
};
|
|
2545
2544
|
const ret = (...args) => {
|
|
2546
|
-
if (isTestEnv()) {
|
|
2547
|
-
fn(...args);
|
|
2548
|
-
return;
|
|
2549
|
-
}
|
|
2550
2545
|
lastArgs = args;
|
|
2551
2546
|
if (timerId === null) {
|
|
2552
|
-
scheduleFunc(
|
|
2553
|
-
} else if (opts?.trailing) {
|
|
2554
|
-
lastArgsTrailing = args;
|
|
2547
|
+
scheduleFunc();
|
|
2555
2548
|
}
|
|
2556
2549
|
};
|
|
2557
2550
|
ret.flush = () => {
|
|
@@ -2560,12 +2553,12 @@ var throttleRAF = (fn, opts) => {
|
|
|
2560
2553
|
timerId = null;
|
|
2561
2554
|
}
|
|
2562
2555
|
if (lastArgs) {
|
|
2563
|
-
fn(...
|
|
2564
|
-
lastArgs =
|
|
2556
|
+
fn(...lastArgs);
|
|
2557
|
+
lastArgs = null;
|
|
2565
2558
|
}
|
|
2566
2559
|
};
|
|
2567
2560
|
ret.cancel = () => {
|
|
2568
|
-
lastArgs =
|
|
2561
|
+
lastArgs = null;
|
|
2569
2562
|
if (timerId !== null) {
|
|
2570
2563
|
cancelAnimationFrame(timerId);
|
|
2571
2564
|
timerId = null;
|
|
@@ -3156,6 +3149,9 @@ var setFeatureFlag = (flag, value) => {
|
|
|
3156
3149
|
console.error("unable to set feature flag", e);
|
|
3157
3150
|
}
|
|
3158
3151
|
};
|
|
3152
|
+
var oneOf = (needle, haystack) => {
|
|
3153
|
+
return haystack.includes(needle);
|
|
3154
|
+
};
|
|
3159
3155
|
|
|
3160
3156
|
// src/random.ts
|
|
3161
3157
|
var random = new Random(Date.now());
|
|
@@ -3229,6 +3225,298 @@ var Emitter = class {
|
|
|
3229
3225
|
this.subscribers = [];
|
|
3230
3226
|
}
|
|
3231
3227
|
};
|
|
3228
|
+
|
|
3229
|
+
// src/appEventBus.ts
|
|
3230
|
+
init_define_import_meta_env();
|
|
3231
|
+
var AppEventBus = class {
|
|
3232
|
+
constructor(behavior) {
|
|
3233
|
+
this.behavior = behavior;
|
|
3234
|
+
}
|
|
3235
|
+
emitters = /* @__PURE__ */ new Map();
|
|
3236
|
+
lastPayload = /* @__PURE__ */ new Map();
|
|
3237
|
+
emittedOnce = /* @__PURE__ */ new Set();
|
|
3238
|
+
getEmitter(name) {
|
|
3239
|
+
let emitter = this.emitters.get(name);
|
|
3240
|
+
if (!emitter) {
|
|
3241
|
+
emitter = new Emitter();
|
|
3242
|
+
this.emitters.set(name, emitter);
|
|
3243
|
+
}
|
|
3244
|
+
return emitter;
|
|
3245
|
+
}
|
|
3246
|
+
toPromiseValue(args) {
|
|
3247
|
+
return args.length === 1 ? args[0] : args;
|
|
3248
|
+
}
|
|
3249
|
+
on(name, callback) {
|
|
3250
|
+
const eventBehavior = this.behavior[name];
|
|
3251
|
+
const cachedPayload = this.lastPayload.get(name);
|
|
3252
|
+
if (callback) {
|
|
3253
|
+
if (eventBehavior.replay === "last" && cachedPayload) {
|
|
3254
|
+
queueMicrotask(() => callback(...cachedPayload));
|
|
3255
|
+
if (eventBehavior.cardinality === "once") {
|
|
3256
|
+
return () => {
|
|
3257
|
+
};
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
return this.getEmitter(name).on(callback);
|
|
3261
|
+
}
|
|
3262
|
+
if (eventBehavior.cardinality !== "once" || eventBehavior.replay !== "last") {
|
|
3263
|
+
throw new Error(`Event "${String(name)}" requires a callback`);
|
|
3264
|
+
}
|
|
3265
|
+
if (cachedPayload) {
|
|
3266
|
+
return Promise.resolve(this.toPromiseValue(cachedPayload));
|
|
3267
|
+
}
|
|
3268
|
+
return new Promise((resolve) => {
|
|
3269
|
+
this.getEmitter(name).once((...args) => {
|
|
3270
|
+
resolve(this.toPromiseValue(args));
|
|
3271
|
+
});
|
|
3272
|
+
});
|
|
3273
|
+
}
|
|
3274
|
+
emit(name, ...args) {
|
|
3275
|
+
const eventBehavior = this.behavior[name];
|
|
3276
|
+
if (!isProdEnv()) {
|
|
3277
|
+
if (eventBehavior.cardinality === "once") {
|
|
3278
|
+
if (this.emittedOnce.has(name)) {
|
|
3279
|
+
throw new Error(`Event "${String(name)}" can only be emitted once`);
|
|
3280
|
+
}
|
|
3281
|
+
this.emittedOnce.add(name);
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
if (eventBehavior.replay === "last") {
|
|
3285
|
+
this.lastPayload.set(name, args);
|
|
3286
|
+
}
|
|
3287
|
+
try {
|
|
3288
|
+
this.getEmitter(name).trigger(...args);
|
|
3289
|
+
} finally {
|
|
3290
|
+
if (eventBehavior.cardinality === "once") {
|
|
3291
|
+
this.getEmitter(name).clear();
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
clear() {
|
|
3296
|
+
this.lastPayload.clear();
|
|
3297
|
+
this.emittedOnce.clear();
|
|
3298
|
+
for (const emitter of this.emitters.values()) {
|
|
3299
|
+
emitter.clear();
|
|
3300
|
+
}
|
|
3301
|
+
this.emitters.clear();
|
|
3302
|
+
}
|
|
3303
|
+
};
|
|
3304
|
+
|
|
3305
|
+
// src/versionedSnapshotStore.ts
|
|
3306
|
+
init_define_import_meta_env();
|
|
3307
|
+
var VersionedSnapshotStore = class {
|
|
3308
|
+
constructor(initialValue, isEqual = Object.is) {
|
|
3309
|
+
this.isEqual = isEqual;
|
|
3310
|
+
this.value = initialValue;
|
|
3311
|
+
}
|
|
3312
|
+
version = 0;
|
|
3313
|
+
value;
|
|
3314
|
+
waiters = /* @__PURE__ */ new Set();
|
|
3315
|
+
subscribers = /* @__PURE__ */ new Set();
|
|
3316
|
+
getSnapshot() {
|
|
3317
|
+
return { version: this.version, value: this.value };
|
|
3318
|
+
}
|
|
3319
|
+
set(nextValue) {
|
|
3320
|
+
if (this.isEqual(this.value, nextValue)) {
|
|
3321
|
+
return false;
|
|
3322
|
+
}
|
|
3323
|
+
this.value = nextValue;
|
|
3324
|
+
this.version += 1;
|
|
3325
|
+
const snapshot = this.getSnapshot();
|
|
3326
|
+
for (const subscriber of this.subscribers) {
|
|
3327
|
+
subscriber(snapshot);
|
|
3328
|
+
}
|
|
3329
|
+
for (const waiter of this.waiters) {
|
|
3330
|
+
waiter(snapshot);
|
|
3331
|
+
}
|
|
3332
|
+
this.waiters.clear();
|
|
3333
|
+
return true;
|
|
3334
|
+
}
|
|
3335
|
+
update(updater) {
|
|
3336
|
+
return this.set(updater(this.value));
|
|
3337
|
+
}
|
|
3338
|
+
subscribe(subscriber) {
|
|
3339
|
+
this.subscribers.add(subscriber);
|
|
3340
|
+
return () => {
|
|
3341
|
+
this.subscribers.delete(subscriber);
|
|
3342
|
+
};
|
|
3343
|
+
}
|
|
3344
|
+
pull(sinceVersion = -1) {
|
|
3345
|
+
if (this.version !== sinceVersion) {
|
|
3346
|
+
return Promise.resolve(this.getSnapshot());
|
|
3347
|
+
}
|
|
3348
|
+
return new Promise((resolve) => {
|
|
3349
|
+
this.waiters.add(resolve);
|
|
3350
|
+
});
|
|
3351
|
+
}
|
|
3352
|
+
};
|
|
3353
|
+
|
|
3354
|
+
// debug.ts
|
|
3355
|
+
init_define_import_meta_env();
|
|
3356
|
+
var lessPrecise = (num, precision = 5) => parseFloat(num.toPrecision(precision));
|
|
3357
|
+
var getAvgFrameTime = (times) => lessPrecise(times.reduce((a, b) => a + b) / times.length);
|
|
3358
|
+
var Debug = class _Debug {
|
|
3359
|
+
static DEBUG_LOG_TIMES = true;
|
|
3360
|
+
static TIMES_AGGR = {};
|
|
3361
|
+
static TIMES_AVG = {};
|
|
3362
|
+
static LAST_DEBUG_LOG_CALL = 0;
|
|
3363
|
+
static DEBUG_LOG_INTERVAL_ID = null;
|
|
3364
|
+
static LAST_FRAME_TIMESTAMP = 0;
|
|
3365
|
+
static FRAME_COUNT = 0;
|
|
3366
|
+
static ANIMATION_FRAME_ID = null;
|
|
3367
|
+
static scheduleAnimationFrame = () => {
|
|
3368
|
+
if (_Debug.DEBUG_LOG_INTERVAL_ID !== null) {
|
|
3369
|
+
_Debug.ANIMATION_FRAME_ID = requestAnimationFrame((timestamp) => {
|
|
3370
|
+
if (_Debug.LAST_FRAME_TIMESTAMP !== timestamp) {
|
|
3371
|
+
_Debug.LAST_FRAME_TIMESTAMP = timestamp;
|
|
3372
|
+
_Debug.FRAME_COUNT++;
|
|
3373
|
+
}
|
|
3374
|
+
if (_Debug.DEBUG_LOG_INTERVAL_ID !== null) {
|
|
3375
|
+
_Debug.scheduleAnimationFrame();
|
|
3376
|
+
}
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
};
|
|
3380
|
+
static setupInterval = () => {
|
|
3381
|
+
if (_Debug.DEBUG_LOG_INTERVAL_ID === null) {
|
|
3382
|
+
console.info("%c(starting perf recording)", "color: lime");
|
|
3383
|
+
_Debug.DEBUG_LOG_INTERVAL_ID = window.setInterval(_Debug.debugLogger, 1e3);
|
|
3384
|
+
_Debug.scheduleAnimationFrame();
|
|
3385
|
+
}
|
|
3386
|
+
_Debug.LAST_DEBUG_LOG_CALL = Date.now();
|
|
3387
|
+
};
|
|
3388
|
+
static debugLogger = () => {
|
|
3389
|
+
if (_Debug.DEBUG_LOG_TIMES) {
|
|
3390
|
+
for (const [name, { t, times }] of Object.entries(_Debug.TIMES_AGGR)) {
|
|
3391
|
+
if (times.length) {
|
|
3392
|
+
console.info(
|
|
3393
|
+
name,
|
|
3394
|
+
lessPrecise(times.reduce((a, b) => a + b)),
|
|
3395
|
+
times.sort((a, b) => a - b).map((x) => lessPrecise(x))
|
|
3396
|
+
);
|
|
3397
|
+
_Debug.TIMES_AGGR[name] = { t, times: [] };
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
for (const [name, { t, times, avg }] of Object.entries(_Debug.TIMES_AVG)) {
|
|
3401
|
+
if (times.length) {
|
|
3402
|
+
const totalTime = times.reduce((a, b) => a + b);
|
|
3403
|
+
const avgFrameTime = lessPrecise(totalTime / _Debug.FRAME_COUNT);
|
|
3404
|
+
console.info(
|
|
3405
|
+
name,
|
|
3406
|
+
`- ${times.length} calls - ${avgFrameTime}ms/frame across ${_Debug.FRAME_COUNT} frames (${lessPrecise(
|
|
3407
|
+
avgFrameTime / 16.67 * 100,
|
|
3408
|
+
1
|
|
3409
|
+
)}% of frame budget)`
|
|
3410
|
+
);
|
|
3411
|
+
_Debug.TIMES_AVG[name] = {
|
|
3412
|
+
t,
|
|
3413
|
+
times: [],
|
|
3414
|
+
avg: avg != null ? getAvgFrameTime([avg, avgFrameTime]) : avgFrameTime
|
|
3415
|
+
};
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
_Debug.FRAME_COUNT = 0;
|
|
3420
|
+
if (Date.now() - _Debug.LAST_DEBUG_LOG_CALL > 600 && _Debug.DEBUG_LOG_INTERVAL_ID !== null) {
|
|
3421
|
+
console.info("%c(stopping perf recording)", "color: red");
|
|
3422
|
+
window.clearInterval(_Debug.DEBUG_LOG_INTERVAL_ID);
|
|
3423
|
+
window.cancelAnimationFrame(_Debug.ANIMATION_FRAME_ID);
|
|
3424
|
+
_Debug.ANIMATION_FRAME_ID = null;
|
|
3425
|
+
_Debug.FRAME_COUNT = 0;
|
|
3426
|
+
_Debug.LAST_FRAME_TIMESTAMP = 0;
|
|
3427
|
+
_Debug.DEBUG_LOG_INTERVAL_ID = null;
|
|
3428
|
+
_Debug.TIMES_AGGR = {};
|
|
3429
|
+
_Debug.TIMES_AVG = {};
|
|
3430
|
+
}
|
|
3431
|
+
};
|
|
3432
|
+
static logTime = (time, name = "default") => {
|
|
3433
|
+
_Debug.setupInterval();
|
|
3434
|
+
const now = performance.now();
|
|
3435
|
+
const { t, times } = _Debug.TIMES_AGGR[name] = _Debug.TIMES_AGGR[name] || {
|
|
3436
|
+
t: 0,
|
|
3437
|
+
times: []
|
|
3438
|
+
};
|
|
3439
|
+
if (t) {
|
|
3440
|
+
times.push(time != null ? time : now - t);
|
|
3441
|
+
}
|
|
3442
|
+
_Debug.TIMES_AGGR[name].t = now;
|
|
3443
|
+
};
|
|
3444
|
+
static logTimeAverage = (time, name = "default") => {
|
|
3445
|
+
_Debug.setupInterval();
|
|
3446
|
+
const now = performance.now();
|
|
3447
|
+
const { t, times } = _Debug.TIMES_AVG[name] = _Debug.TIMES_AVG[name] || {
|
|
3448
|
+
t: 0,
|
|
3449
|
+
times: []
|
|
3450
|
+
};
|
|
3451
|
+
if (t) {
|
|
3452
|
+
times.push(time != null ? time : now - t);
|
|
3453
|
+
}
|
|
3454
|
+
_Debug.TIMES_AVG[name].t = now;
|
|
3455
|
+
};
|
|
3456
|
+
static logWrapper = (type) => (fn, name = "default") => {
|
|
3457
|
+
return (...args) => {
|
|
3458
|
+
const t0 = performance.now();
|
|
3459
|
+
const ret = fn(...args);
|
|
3460
|
+
_Debug[type](performance.now() - t0, name);
|
|
3461
|
+
return ret;
|
|
3462
|
+
};
|
|
3463
|
+
};
|
|
3464
|
+
static logTimeWrap = _Debug.logWrapper("logTime");
|
|
3465
|
+
static logTimeAverageWrap = _Debug.logWrapper("logTimeAverage");
|
|
3466
|
+
static perfWrap = (fn, name = "default") => {
|
|
3467
|
+
return (...args) => {
|
|
3468
|
+
console.time(name);
|
|
3469
|
+
const ret = fn(...args);
|
|
3470
|
+
console.timeEnd(name);
|
|
3471
|
+
return ret;
|
|
3472
|
+
};
|
|
3473
|
+
};
|
|
3474
|
+
static CHANGED_CACHE = {};
|
|
3475
|
+
static logChanged(name, obj) {
|
|
3476
|
+
const prev = _Debug.CHANGED_CACHE[name];
|
|
3477
|
+
_Debug.CHANGED_CACHE[name] = obj;
|
|
3478
|
+
if (!prev) {
|
|
3479
|
+
return;
|
|
3480
|
+
}
|
|
3481
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(obj)]);
|
|
3482
|
+
const changed = {};
|
|
3483
|
+
for (const key of allKeys) {
|
|
3484
|
+
const prevVal = prev[key];
|
|
3485
|
+
const nextVal = obj[key];
|
|
3486
|
+
if (!deepEqual(prevVal, nextVal)) {
|
|
3487
|
+
changed[key] = { prev: prevVal, next: nextVal };
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
if (Object.keys(changed).length > 0) {
|
|
3491
|
+
console.info(`[${name}] changed:`, changed);
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3494
|
+
};
|
|
3495
|
+
function deepEqual(a, b) {
|
|
3496
|
+
if (Object.is(a, b)) {
|
|
3497
|
+
return true;
|
|
3498
|
+
}
|
|
3499
|
+
if (a === null || b === null || typeof a !== "object" || typeof b !== "object") {
|
|
3500
|
+
return false;
|
|
3501
|
+
}
|
|
3502
|
+
if (Array.isArray(a) !== Array.isArray(b)) {
|
|
3503
|
+
return false;
|
|
3504
|
+
}
|
|
3505
|
+
const keysA = Object.keys(a);
|
|
3506
|
+
const keysB = Object.keys(b);
|
|
3507
|
+
if (keysA.length !== keysB.length) {
|
|
3508
|
+
return false;
|
|
3509
|
+
}
|
|
3510
|
+
for (const key of keysA) {
|
|
3511
|
+
if (!deepEqual(
|
|
3512
|
+
a[key],
|
|
3513
|
+
b[key]
|
|
3514
|
+
)) {
|
|
3515
|
+
return false;
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
return true;
|
|
3519
|
+
}
|
|
3232
3520
|
export {
|
|
3233
3521
|
ACTIVE_THRESHOLD,
|
|
3234
3522
|
ALLOWED_PASTE_MIME_TYPES,
|
|
@@ -3236,6 +3524,7 @@ export {
|
|
|
3236
3524
|
ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO,
|
|
3237
3525
|
ARROW_LABEL_WIDTH_FRACTION,
|
|
3238
3526
|
ARROW_TYPE,
|
|
3527
|
+
AppEventBus,
|
|
3239
3528
|
BIND_MODE_TIMEOUT,
|
|
3240
3529
|
BOUND_TEXT_PADDING,
|
|
3241
3530
|
BinaryHeap,
|
|
@@ -3281,6 +3570,7 @@ export {
|
|
|
3281
3570
|
DEFAULT_VERTICAL_ALIGN,
|
|
3282
3571
|
DOUBLE_TAP_POSITION_THRESHOLD,
|
|
3283
3572
|
DRAGGING_THRESHOLD,
|
|
3573
|
+
Debug,
|
|
3284
3574
|
EDITOR_LS_KEYS,
|
|
3285
3575
|
ELEMENT_LINK_KEY,
|
|
3286
3576
|
ELEMENT_READY_TO_ERASE_OPACITY,
|
|
@@ -3360,6 +3650,7 @@ export {
|
|
|
3360
3650
|
VERSIONS,
|
|
3361
3651
|
VERSION_TIMEOUT,
|
|
3362
3652
|
VERTICAL_ALIGN,
|
|
3653
|
+
VersionedSnapshotStore,
|
|
3363
3654
|
WINDOWS_EMOJI_FALLBACK_FONT,
|
|
3364
3655
|
YOUTUBE_STATES,
|
|
3365
3656
|
ZOOM_STEP,
|
|
@@ -3453,6 +3744,7 @@ export {
|
|
|
3453
3744
|
normalizeEOL,
|
|
3454
3745
|
normalizeInputColor,
|
|
3455
3746
|
normalizeLink,
|
|
3747
|
+
oneOf,
|
|
3456
3748
|
preventUnload,
|
|
3457
3749
|
promiseTry,
|
|
3458
3750
|
queryFocusableElements,
|