y-mxgraph 0.5.2 → 0.5.6
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/README.md +12 -14
- package/README.zh-CN.md +12 -14
- package/helper/throttle.d.ts +2 -0
- package/helper/throttle.d.ts.map +1 -0
- package/package.json +1 -3
- package/y-mxgraph.cjs.js +29 -2
- package/y-mxgraph.cjs.js.map +1 -1
- package/y-mxgraph.es.js +28 -1
- package/y-mxgraph.es.js.map +1 -1
package/y-mxgraph.es.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { xml2js, js2xml } from "xml-js";
|
|
2
2
|
import * as Y from "yjs";
|
|
3
|
-
import { throttle } from "lodash-es";
|
|
4
3
|
import { colord } from "colord";
|
|
5
4
|
function deepProcess(node) {
|
|
6
5
|
if (node == null) return;
|
|
@@ -1045,6 +1044,34 @@ function hslToHex(h, s, l) {
|
|
|
1045
1044
|
const b = Math.round((b1 + m) * 255);
|
|
1046
1045
|
return "#" + [r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("");
|
|
1047
1046
|
}
|
|
1047
|
+
function throttle(fn, wait) {
|
|
1048
|
+
let lastTime = 0;
|
|
1049
|
+
let timeoutId = null;
|
|
1050
|
+
let lastArgs = null;
|
|
1051
|
+
return (...args) => {
|
|
1052
|
+
const now = Date.now();
|
|
1053
|
+
const remaining = wait - (now - lastTime);
|
|
1054
|
+
lastArgs = args;
|
|
1055
|
+
if (remaining <= 0) {
|
|
1056
|
+
if (timeoutId) {
|
|
1057
|
+
clearTimeout(timeoutId);
|
|
1058
|
+
timeoutId = null;
|
|
1059
|
+
}
|
|
1060
|
+
lastTime = now;
|
|
1061
|
+
return fn(...args);
|
|
1062
|
+
}
|
|
1063
|
+
if (!timeoutId) {
|
|
1064
|
+
timeoutId = setTimeout(() => {
|
|
1065
|
+
lastTime = Date.now();
|
|
1066
|
+
timeoutId = null;
|
|
1067
|
+
if (lastArgs) {
|
|
1068
|
+
fn(...lastArgs);
|
|
1069
|
+
}
|
|
1070
|
+
}, remaining);
|
|
1071
|
+
}
|
|
1072
|
+
return void 0;
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1048
1075
|
function createCursorImage(color) {
|
|
1049
1076
|
const w = 8;
|
|
1050
1077
|
const h = 12;
|