@idraw/util 0.4.0-beta.40 → 0.4.0-beta.42
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/esm/index.d.ts +46 -40
- package/dist/esm/index.js +46 -40
- package/dist/esm/tool/flat-object.d.ts +6 -0
- package/dist/esm/tool/flat-object.js +28 -0
- package/dist/esm/tool/get-set-del.d.ts +4 -0
- package/dist/esm/tool/get-set-del.js +65 -0
- package/dist/esm/{lib → tool}/html.js +6 -2
- package/dist/esm/{lib → tool}/store.js +1 -1
- package/dist/esm/tool/unflat-object.d.ts +3 -0
- package/dist/esm/tool/unflat-object.js +91 -0
- package/dist/esm/{lib → tool}/uuid.d.ts +1 -1
- package/dist/esm/tool/uuid.js +39 -0
- package/dist/esm/{lib → view}/check.js +14 -14
- package/dist/esm/{lib → view}/controller.js +53 -10
- package/dist/esm/{lib → view}/data.js +7 -7
- package/dist/esm/{lib → view}/element.js +13 -5
- package/dist/esm/{lib → view}/flat.js +2 -1
- package/dist/esm/{lib → view}/group.js +1 -1
- package/dist/esm/{lib → view}/handle-element.d.ts +6 -1
- package/dist/esm/{lib → view}/handle-element.js +26 -31
- package/dist/esm/view/handle-global.d.ts +4 -0
- package/dist/esm/view/handle-global.js +28 -0
- package/dist/esm/view/handle-layout.d.ts +4 -0
- package/dist/esm/view/handle-layout.js +28 -0
- package/dist/esm/{lib → view}/is.js +1 -1
- package/dist/esm/view/modify-record.d.ts +4 -0
- package/dist/esm/view/modify-record.js +10 -0
- package/dist/esm/view/position.d.ts +15 -0
- package/dist/esm/view/position.js +79 -0
- package/dist/esm/{lib → view}/resize-element.js +1 -1
- package/dist/esm/{lib → view}/view-content.js +1 -1
- package/dist/index.global.js +455 -166
- package/dist/index.global.min.js +1 -1
- package/package.json +1 -1
- package/dist/esm/lib/modify-recorder.d.ts +0 -15
- package/dist/esm/lib/modify-recorder.js +0 -177
- package/dist/esm/lib/modify.d.ts +0 -6
- package/dist/esm/lib/modify.js +0 -99
- package/dist/esm/lib/uuid.js +0 -31
- /package/dist/esm/{lib → tool}/color.d.ts +0 -0
- /package/dist/esm/{lib → tool}/color.js +0 -0
- /package/dist/esm/{lib → tool}/event.d.ts +0 -0
- /package/dist/esm/{lib → tool}/event.js +0 -0
- /package/dist/esm/{lib → tool}/file.d.ts +0 -0
- /package/dist/esm/{lib → tool}/file.js +0 -0
- /package/dist/esm/{lib → tool}/html.d.ts +0 -0
- /package/dist/esm/{lib → tool}/image.d.ts +0 -0
- /package/dist/esm/{lib → tool}/image.js +0 -0
- /package/dist/esm/{lib → tool}/istype.d.ts +0 -0
- /package/dist/esm/{lib → tool}/istype.js +0 -0
- /package/dist/esm/{lib → tool}/merge.d.ts +0 -0
- /package/dist/esm/{lib → tool}/merge.js +0 -0
- /package/dist/esm/{lib → tool}/number.d.ts +0 -0
- /package/dist/esm/{lib → tool}/number.js +0 -0
- /package/dist/esm/{lib → tool}/omit.d.ts +0 -0
- /package/dist/esm/{lib → tool}/omit.js +0 -0
- /package/dist/esm/{lib → tool}/store.d.ts +0 -0
- /package/dist/esm/{lib → tool}/time.d.ts +0 -0
- /package/dist/esm/{lib → tool}/time.js +0 -0
- /package/dist/esm/{lib → view}/box.d.ts +0 -0
- /package/dist/esm/{lib → view}/box.js +0 -0
- /package/dist/esm/{lib → view}/canvas.d.ts +0 -0
- /package/dist/esm/{lib → view}/canvas.js +0 -0
- /package/dist/esm/{lib → view}/check.d.ts +0 -0
- /package/dist/esm/{lib → view}/config.d.ts +0 -0
- /package/dist/esm/{lib → view}/config.js +0 -0
- /package/dist/esm/{lib → view}/context2d.d.ts +0 -0
- /package/dist/esm/{lib → view}/context2d.js +0 -0
- /package/dist/esm/{lib → view}/controller.d.ts +0 -0
- /package/dist/esm/{lib → view}/data.d.ts +0 -0
- /package/dist/esm/{lib → view}/element.d.ts +0 -0
- /package/dist/esm/{lib → view}/flat.d.ts +0 -0
- /package/dist/esm/{lib → view}/group.d.ts +0 -0
- /package/dist/esm/{lib → view}/is.d.ts +0 -0
- /package/dist/esm/{lib → view}/load.d.ts +0 -0
- /package/dist/esm/{lib → view}/load.js +0 -0
- /package/dist/esm/{lib → view}/matrix.d.ts +0 -0
- /package/dist/esm/{lib → view}/matrix.js +0 -0
- /package/dist/esm/{lib → view}/middleware.d.ts +0 -0
- /package/dist/esm/{lib → view}/middleware.js +0 -0
- /package/dist/esm/{lib → view}/parser.d.ts +0 -0
- /package/dist/esm/{lib → view}/parser.js +0 -0
- /package/dist/esm/{lib → view}/point-move-element.d.ts +0 -0
- /package/dist/esm/{lib → view}/point-move-element.js +0 -0
- /package/dist/esm/{lib → view}/point.d.ts +0 -0
- /package/dist/esm/{lib → view}/point.js +0 -0
- /package/dist/esm/{lib → view}/rect.d.ts +0 -0
- /package/dist/esm/{lib → view}/rect.js +0 -0
- /package/dist/esm/{lib → view}/resize-element.d.ts +0 -0
- /package/dist/esm/{lib → view}/rotate.d.ts +0 -0
- /package/dist/esm/{lib → view}/rotate.js +0 -0
- /package/dist/esm/{lib → view}/svg-path.d.ts +0 -0
- /package/dist/esm/{lib → view}/svg-path.js +0 -0
- /package/dist/esm/{lib → view}/text.d.ts +0 -0
- /package/dist/esm/{lib → view}/text.js +0 -0
- /package/dist/esm/{lib → view}/vertex.d.ts +0 -0
- /package/dist/esm/{lib → view}/vertex.js +0 -0
- /package/dist/esm/{lib → view}/view-box.d.ts +0 -0
- /package/dist/esm/{lib → view}/view-box.js +0 -0
- /package/dist/esm/{lib → view}/view-calc.d.ts +0 -0
- /package/dist/esm/{lib → view}/view-calc.js +0 -0
- /package/dist/esm/{lib → view}/view-content.d.ts +0 -0
package/dist/index.global.js
CHANGED
|
@@ -377,30 +377,38 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
377
377
|
}
|
|
378
378
|
return `${_createStr()}${_createStr()}-${_createStr()}-${_createStr()}-${_createStr()}-${_createStr()}${_createStr()}${_createStr()}`;
|
|
379
379
|
}
|
|
380
|
-
function limitHexStr(str) {
|
|
380
|
+
function limitHexStr(str, seed) {
|
|
381
381
|
let count = 0;
|
|
382
382
|
for (let i = 0; i < str.length; i++) {
|
|
383
|
-
count += str.charCodeAt(i)
|
|
383
|
+
count += str.charCodeAt(i);
|
|
384
384
|
}
|
|
385
|
-
return count.toString(16).substring(0, 4);
|
|
385
|
+
return (count + seed).toString(16).substring(0, 4);
|
|
386
386
|
}
|
|
387
|
-
function
|
|
387
|
+
function sumCharCodes(str) {
|
|
388
|
+
let sum = 0;
|
|
389
|
+
for (let i = 0; i < str.length; i++) {
|
|
390
|
+
sum += str.charCodeAt(i);
|
|
391
|
+
}
|
|
392
|
+
return sum;
|
|
393
|
+
}
|
|
394
|
+
function createAssetId(assetStr, elemUUID) {
|
|
388
395
|
const len = assetStr.length;
|
|
396
|
+
const seed = sumCharCodes(elemUUID);
|
|
389
397
|
const mid = Math.floor(len / 2);
|
|
390
|
-
const start4 = assetStr.substring(0, 4).
|
|
391
|
-
const end4 = assetStr.substring(0, 4).
|
|
392
|
-
const str1 = limitHexStr(len.toString(16).
|
|
393
|
-
const str2 = limitHexStr(assetStr.substring(mid - 4, mid).
|
|
394
|
-
const str3 = limitHexStr(assetStr.substring(mid - 8, mid - 4).
|
|
395
|
-
const str4 = limitHexStr(assetStr.substring(mid - 12, mid - 8).
|
|
396
|
-
const str5 = limitHexStr(assetStr.substring(mid - 16, mid - 12).
|
|
397
|
-
const str6 = limitHexStr(assetStr.substring(mid, mid + 4).
|
|
398
|
-
const str7 = limitHexStr(assetStr.substring(mid + 4, mid + 8).
|
|
399
|
-
const str8 = limitHexStr(end4.
|
|
398
|
+
const start4 = assetStr.substring(0, 4).padStart(4, "0");
|
|
399
|
+
const end4 = assetStr.substring(0, 4).padStart(4, "0");
|
|
400
|
+
const str1 = limitHexStr(len.toString(16).padStart(4, start4), seed).padStart(4, "0");
|
|
401
|
+
const str2 = limitHexStr(assetStr.substring(mid - 4, mid).padStart(4, start4), seed).padStart(4, "0");
|
|
402
|
+
const str3 = limitHexStr(assetStr.substring(mid - 8, mid - 4).padStart(4, start4), seed).padStart(4, "0");
|
|
403
|
+
const str4 = limitHexStr(assetStr.substring(mid - 12, mid - 8).padStart(4, start4), seed).padStart(4, "0");
|
|
404
|
+
const str5 = limitHexStr(assetStr.substring(mid - 16, mid - 12).padStart(4, end4), seed).padStart(4, "0");
|
|
405
|
+
const str6 = limitHexStr(assetStr.substring(mid, mid + 4).padStart(4, end4), seed).padStart(4, "0");
|
|
406
|
+
const str7 = limitHexStr(assetStr.substring(mid + 4, mid + 8).padStart(4, end4), seed).padStart(4, "0");
|
|
407
|
+
const str8 = limitHexStr(end4.padStart(4, start4).padStart(4, end4), seed);
|
|
400
408
|
return `@assets/${str1}${str2}-${str3}-${str4}-${str5}-${str6}${str7}${str8}`;
|
|
401
409
|
}
|
|
402
410
|
function isAssetId(id) {
|
|
403
|
-
return /^@assets\/[0-9a-z
|
|
411
|
+
return /^@assets\/[0-9a-z-]{0,}$/.test(`${id}`);
|
|
404
412
|
}
|
|
405
413
|
function deepClone(target) {
|
|
406
414
|
function _clone(t) {
|
|
@@ -463,7 +471,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
463
471
|
elems.forEach((elem) => {
|
|
464
472
|
if (elem.type === "image" && elem.detail.src) {
|
|
465
473
|
const src = elem.detail.src;
|
|
466
|
-
const assetUUID = createAssetId(src);
|
|
474
|
+
const assetUUID = createAssetId(src, elem.uuid);
|
|
467
475
|
if (!assets[assetUUID]) {
|
|
468
476
|
assets[assetUUID] = {
|
|
469
477
|
type: "image",
|
|
@@ -473,7 +481,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
473
481
|
elem.detail.src = assetUUID;
|
|
474
482
|
} else if (elem.type === "svg") {
|
|
475
483
|
const svg2 = elem.detail.svg;
|
|
476
|
-
const assetUUID = createAssetId(svg2);
|
|
484
|
+
const assetUUID = createAssetId(svg2, elem.uuid);
|
|
477
485
|
if (!assets[assetUUID]) {
|
|
478
486
|
assets[assetUUID] = {
|
|
479
487
|
type: "svg",
|
|
@@ -483,7 +491,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
483
491
|
elem.detail.svg = assetUUID;
|
|
484
492
|
} else if (elem.type === "html") {
|
|
485
493
|
const html2 = elem.detail.html;
|
|
486
|
-
const assetUUID = createAssetId(html2);
|
|
494
|
+
const assetUUID = createAssetId(html2, elem.uuid);
|
|
487
495
|
if (!assets[assetUUID]) {
|
|
488
496
|
assets[assetUUID] = {
|
|
489
497
|
type: "html",
|
|
@@ -522,7 +530,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
522
530
|
value: loadItemMap[src].source
|
|
523
531
|
};
|
|
524
532
|
} else if (!assets[src]) {
|
|
525
|
-
const assetUUID = createAssetId(src);
|
|
533
|
+
const assetUUID = createAssetId(src, elem.uuid);
|
|
526
534
|
if (!assets[assetUUID]) {
|
|
527
535
|
assets[assetUUID] = {
|
|
528
536
|
type: "image",
|
|
@@ -539,7 +547,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
539
547
|
value: loadItemMap[svg2].source
|
|
540
548
|
};
|
|
541
549
|
} else if (!assets[svg2]) {
|
|
542
|
-
const assetUUID = createAssetId(svg2);
|
|
550
|
+
const assetUUID = createAssetId(svg2, elem.uuid);
|
|
543
551
|
if (!assets[assetUUID]) {
|
|
544
552
|
assets[assetUUID] = {
|
|
545
553
|
type: "svg",
|
|
@@ -556,7 +564,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
556
564
|
value: loadItemMap[html2].source
|
|
557
565
|
};
|
|
558
566
|
} else if (!assets[html2]) {
|
|
559
|
-
const assetUUID = createAssetId(html2);
|
|
567
|
+
const assetUUID = createAssetId(html2, elem.uuid);
|
|
560
568
|
if (!assets[assetUUID]) {
|
|
561
569
|
assets[assetUUID] = {
|
|
562
570
|
type: "html",
|
|
@@ -814,20 +822,20 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
814
822
|
}
|
|
815
823
|
function box(detail = {}) {
|
|
816
824
|
const { borderColor, borderRadius: borderRadius2, borderWidth: borderWidth2 } = detail;
|
|
817
|
-
if (
|
|
825
|
+
if (Object.prototype.hasOwnProperty.call(detail, "borderColor") && !is.color(borderColor)) {
|
|
818
826
|
return false;
|
|
819
827
|
}
|
|
820
|
-
if (
|
|
828
|
+
if (Object.prototype.hasOwnProperty.call(detail, "borderRadius") && !is.number(borderRadius2)) {
|
|
821
829
|
return false;
|
|
822
830
|
}
|
|
823
|
-
if (
|
|
831
|
+
if (Object.prototype.hasOwnProperty.call(detail, "borderWidth") && !is.number(borderWidth2)) {
|
|
824
832
|
return false;
|
|
825
833
|
}
|
|
826
834
|
return true;
|
|
827
835
|
}
|
|
828
836
|
function rectDesc(detail) {
|
|
829
837
|
const { background } = detail;
|
|
830
|
-
if (
|
|
838
|
+
if (Object.prototype.hasOwnProperty.call(detail, "background") && !is.color(background)) {
|
|
831
839
|
return false;
|
|
832
840
|
}
|
|
833
841
|
if (!box(detail)) {
|
|
@@ -837,13 +845,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
837
845
|
}
|
|
838
846
|
function circleDesc(detail) {
|
|
839
847
|
const { background, borderColor, borderWidth: borderWidth2 } = detail;
|
|
840
|
-
if (
|
|
848
|
+
if (Object.prototype.hasOwnProperty.call(detail, "background") && !is.color(background)) {
|
|
841
849
|
return false;
|
|
842
850
|
}
|
|
843
|
-
if (
|
|
851
|
+
if (Object.prototype.hasOwnProperty.call(detail, "borderColor") && !is.color(borderColor)) {
|
|
844
852
|
return false;
|
|
845
853
|
}
|
|
846
|
-
if (
|
|
854
|
+
if (Object.prototype.hasOwnProperty.call(detail, "borderWidth") && !is.number(borderWidth2)) {
|
|
847
855
|
return false;
|
|
848
856
|
}
|
|
849
857
|
return true;
|
|
@@ -880,25 +888,25 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
880
888
|
if (!is.fontSize(fontSize2)) {
|
|
881
889
|
return false;
|
|
882
890
|
}
|
|
883
|
-
if (
|
|
891
|
+
if (Object.prototype.hasOwnProperty.call(detail, "background") && !is.color(background)) {
|
|
884
892
|
return false;
|
|
885
893
|
}
|
|
886
|
-
if (
|
|
894
|
+
if (Object.prototype.hasOwnProperty.call(detail, "fontWeight") && !is.fontWeight(fontWeight2)) {
|
|
887
895
|
return false;
|
|
888
896
|
}
|
|
889
|
-
if (
|
|
897
|
+
if (Object.prototype.hasOwnProperty.call(detail, "lineHeight") && !is.lineHeight(lineHeight2)) {
|
|
890
898
|
return false;
|
|
891
899
|
}
|
|
892
|
-
if (
|
|
900
|
+
if (Object.prototype.hasOwnProperty.call(detail, "fontFamily") && !is.fontFamily(fontFamily2)) {
|
|
893
901
|
return false;
|
|
894
902
|
}
|
|
895
|
-
if (
|
|
903
|
+
if (Object.prototype.hasOwnProperty.call(detail, "textAlign") && !is.textAlign(textAlign2)) {
|
|
896
904
|
return false;
|
|
897
905
|
}
|
|
898
|
-
if (
|
|
906
|
+
if (Object.prototype.hasOwnProperty.call(detail, "strokeWidth") && !is.strokeWidth(strokeWidth2)) {
|
|
899
907
|
return false;
|
|
900
908
|
}
|
|
901
|
-
if (
|
|
909
|
+
if (Object.prototype.hasOwnProperty.call(detail, "strokeColor") && !is.color(strokeColor)) {
|
|
902
910
|
return false;
|
|
903
911
|
}
|
|
904
912
|
if (!box(detail)) {
|
|
@@ -1815,7 +1823,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1815
1823
|
return ctxSize;
|
|
1816
1824
|
}
|
|
1817
1825
|
function calcElementsViewInfo(elements, prevViewSize, options) {
|
|
1818
|
-
const contextSize = calcElementsContextSize(elements, {
|
|
1826
|
+
const contextSize = calcElementsContextSize(elements, {
|
|
1827
|
+
viewWidth: prevViewSize.width,
|
|
1828
|
+
viewHeight: prevViewSize.height,
|
|
1829
|
+
extend: options == null ? void 0 : options.extend
|
|
1830
|
+
});
|
|
1819
1831
|
if ((options == null ? void 0 : options.extend) === true) {
|
|
1820
1832
|
contextSize.contextWidth = Math.max(contextSize.contextWidth, prevViewSize.contextWidth);
|
|
1821
1833
|
contextSize.contextHeight = Math.max(contextSize.contextHeight, prevViewSize.contextHeight);
|
|
@@ -1961,7 +1973,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1961
1973
|
resource = element.detail.html;
|
|
1962
1974
|
}
|
|
1963
1975
|
if (typeof resource === "string" && !isAssetId(resource)) {
|
|
1964
|
-
assetId = createAssetId(resource);
|
|
1976
|
+
assetId = createAssetId(resource, element.uuid);
|
|
1965
1977
|
assetItem = {
|
|
1966
1978
|
type: element.type,
|
|
1967
1979
|
value: resource
|
|
@@ -1999,7 +2011,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1999
2011
|
for (let i = 0; i < position.length; i++) {
|
|
2000
2012
|
const pos = position[i];
|
|
2001
2013
|
const item = tempList[pos];
|
|
2002
|
-
if (i < position.length - 1 && item.type === "group") {
|
|
2014
|
+
if (i < position.length - 1 && (item == null ? void 0 : item.type) === "group") {
|
|
2003
2015
|
tempList = item.detail.children;
|
|
2004
2016
|
} else if (i === position.length - 1) {
|
|
2005
2017
|
result = item;
|
|
@@ -2576,15 +2588,38 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2576
2588
|
const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: totalAngle });
|
|
2577
2589
|
const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: totalAngle });
|
|
2578
2590
|
const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: totalAngle });
|
|
2579
|
-
const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, {
|
|
2591
|
+
const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, {
|
|
2592
|
+
size: ctrlSize,
|
|
2593
|
+
angle: totalAngle
|
|
2594
|
+
});
|
|
2580
2595
|
const topLeftVertexes = calcElementVertexes(topLeftSize);
|
|
2581
2596
|
const topRightVertexes = calcElementVertexes(topRightSize);
|
|
2582
2597
|
const bottomLeftVertexes = calcElementVertexes(bottomLeftSize);
|
|
2583
2598
|
const bottomRightVertexes = calcElementVertexes(bottomRightSize);
|
|
2584
|
-
const topVertexes = [
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2599
|
+
const topVertexes = [
|
|
2600
|
+
topLeftVertexes[1],
|
|
2601
|
+
topRightVertexes[0],
|
|
2602
|
+
topRightVertexes[3],
|
|
2603
|
+
topLeftVertexes[2]
|
|
2604
|
+
];
|
|
2605
|
+
const rightVertexes = [
|
|
2606
|
+
topRightVertexes[3],
|
|
2607
|
+
topRightVertexes[2],
|
|
2608
|
+
bottomRightVertexes[1],
|
|
2609
|
+
bottomRightVertexes[0]
|
|
2610
|
+
];
|
|
2611
|
+
const bottomVertexes = [
|
|
2612
|
+
bottomLeftVertexes[1],
|
|
2613
|
+
bottomRightVertexes[0],
|
|
2614
|
+
bottomRightVertexes[3],
|
|
2615
|
+
bottomLeftVertexes[2]
|
|
2616
|
+
];
|
|
2617
|
+
const leftVertexes = [
|
|
2618
|
+
topLeftVertexes[3],
|
|
2619
|
+
topLeftVertexes[2],
|
|
2620
|
+
bottomLeftVertexes[1],
|
|
2621
|
+
bottomLeftVertexes[0]
|
|
2622
|
+
];
|
|
2588
2623
|
const topMiddleVertexes = calcElementVertexes(topMiddleSize);
|
|
2589
2624
|
const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
|
|
2590
2625
|
const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
|
|
@@ -2706,10 +2741,30 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2706
2741
|
const topRightVertexes = calcElementVertexes(topRightSize);
|
|
2707
2742
|
const bottomLeftVertexes = calcElementVertexes(bottomLeftSize);
|
|
2708
2743
|
const bottomRightVertexes = calcElementVertexes(bottomRightSize);
|
|
2709
|
-
const topVertexes = [
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2744
|
+
const topVertexes = [
|
|
2745
|
+
topLeftVertexes[1],
|
|
2746
|
+
topRightVertexes[0],
|
|
2747
|
+
topRightVertexes[3],
|
|
2748
|
+
topLeftVertexes[2]
|
|
2749
|
+
];
|
|
2750
|
+
const rightVertexes = [
|
|
2751
|
+
topRightVertexes[3],
|
|
2752
|
+
topRightVertexes[2],
|
|
2753
|
+
bottomRightVertexes[1],
|
|
2754
|
+
bottomRightVertexes[0]
|
|
2755
|
+
];
|
|
2756
|
+
const bottomVertexes = [
|
|
2757
|
+
bottomLeftVertexes[1],
|
|
2758
|
+
bottomRightVertexes[0],
|
|
2759
|
+
bottomRightVertexes[3],
|
|
2760
|
+
bottomLeftVertexes[2]
|
|
2761
|
+
];
|
|
2762
|
+
const leftVertexes = [
|
|
2763
|
+
topLeftVertexes[3],
|
|
2764
|
+
topLeftVertexes[2],
|
|
2765
|
+
bottomLeftVertexes[1],
|
|
2766
|
+
bottomLeftVertexes[0]
|
|
2767
|
+
];
|
|
2713
2768
|
const topMiddleVertexes = calcElementVertexes(topMiddleSize);
|
|
2714
2769
|
const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
|
|
2715
2770
|
const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
|
|
@@ -2945,7 +3000,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2945
3000
|
}
|
|
2946
3001
|
function attrString(attrs2) {
|
|
2947
3002
|
const buff = [];
|
|
2948
|
-
for (
|
|
3003
|
+
for (const key in attrs2) {
|
|
2949
3004
|
buff.push(key + '="' + attrs2[key] + '"');
|
|
2950
3005
|
}
|
|
2951
3006
|
if (!buff.length) {
|
|
@@ -3147,6 +3202,106 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3147
3202
|
radiusList
|
|
3148
3203
|
};
|
|
3149
3204
|
}
|
|
3205
|
+
function flattenObject(obj, parentKey = "", result = {}, opts) {
|
|
3206
|
+
Object.keys(obj).forEach((key) => {
|
|
3207
|
+
var _a;
|
|
3208
|
+
const currentKey = parentKey ? `${parentKey}${isArrayIndex$1(key) ? `[${key}]` : `.${key}`}` : key;
|
|
3209
|
+
if (!((_a = opts == null ? void 0 : opts.ignorePaths) == null ? void 0 : _a.includes(currentKey))) {
|
|
3210
|
+
const value = obj[key];
|
|
3211
|
+
if (isFlattenable(value)) {
|
|
3212
|
+
flattenObject(value, Array.isArray(value) ? currentKey : currentKey, result, opts);
|
|
3213
|
+
} else {
|
|
3214
|
+
result[currentKey] = value;
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
});
|
|
3218
|
+
return result;
|
|
3219
|
+
}
|
|
3220
|
+
function isFlattenable(value) {
|
|
3221
|
+
return typeof value === "object" && value !== null && !(value instanceof Date) || Array.isArray(value);
|
|
3222
|
+
}
|
|
3223
|
+
function isArrayIndex$1(key) {
|
|
3224
|
+
return /^\d+$/.test(key) && !isNaN(Number(key));
|
|
3225
|
+
}
|
|
3226
|
+
function flatObject(obj, opts) {
|
|
3227
|
+
if (typeof obj !== "object" || obj === null) {
|
|
3228
|
+
return { "": obj };
|
|
3229
|
+
}
|
|
3230
|
+
return flattenObject(obj, "", {}, opts);
|
|
3231
|
+
}
|
|
3232
|
+
function toFlattenElement(elem) {
|
|
3233
|
+
return flatObject(elem, { ignorePaths: ["detail.children"] });
|
|
3234
|
+
}
|
|
3235
|
+
function toFlattenLayout(layout) {
|
|
3236
|
+
return flatObject(layout);
|
|
3237
|
+
}
|
|
3238
|
+
function toFlattenGlobal(global) {
|
|
3239
|
+
return flatObject(global);
|
|
3240
|
+
}
|
|
3241
|
+
function toPath(path) {
|
|
3242
|
+
if (Array.isArray(path)) return [...path];
|
|
3243
|
+
return path.split(/\.|\[|\]/).filter((key) => key !== "");
|
|
3244
|
+
}
|
|
3245
|
+
function get(obj, path, defaultValue) {
|
|
3246
|
+
if (!path) {
|
|
3247
|
+
return void 0;
|
|
3248
|
+
}
|
|
3249
|
+
const pathArray = toPath(path);
|
|
3250
|
+
let current = obj;
|
|
3251
|
+
for (const key of pathArray) {
|
|
3252
|
+
if (current === null || current === void 0) {
|
|
3253
|
+
return defaultValue;
|
|
3254
|
+
}
|
|
3255
|
+
current = current[key];
|
|
3256
|
+
}
|
|
3257
|
+
return current !== void 0 ? current : defaultValue;
|
|
3258
|
+
}
|
|
3259
|
+
function set(obj, path, value) {
|
|
3260
|
+
const pathArray = toPath(path);
|
|
3261
|
+
if (pathArray.length === 0) {
|
|
3262
|
+
return obj;
|
|
3263
|
+
}
|
|
3264
|
+
let current = obj;
|
|
3265
|
+
if (current) {
|
|
3266
|
+
for (let i = 0; i < pathArray.length; i++) {
|
|
3267
|
+
const key = pathArray[i];
|
|
3268
|
+
if (i === pathArray.length - 1) {
|
|
3269
|
+
current[key] = value;
|
|
3270
|
+
break;
|
|
3271
|
+
}
|
|
3272
|
+
if (current && ((current == null ? void 0 : current[key]) === void 0 || typeof (current == null ? void 0 : current[key]) !== "object" || (current == null ? void 0 : current[key]) === null)) {
|
|
3273
|
+
const nextKey = pathArray[i + 1];
|
|
3274
|
+
const isNextNumeric = /^\d+$/.test(nextKey);
|
|
3275
|
+
current[key] = isNextNumeric ? [] : {};
|
|
3276
|
+
}
|
|
3277
|
+
current = current == null ? void 0 : current[key];
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
return obj;
|
|
3281
|
+
}
|
|
3282
|
+
function del(obj, path) {
|
|
3283
|
+
const pathArray = toPath(path);
|
|
3284
|
+
if (pathArray.length === 0) {
|
|
3285
|
+
return obj;
|
|
3286
|
+
}
|
|
3287
|
+
let current = obj;
|
|
3288
|
+
if (current) {
|
|
3289
|
+
for (let i = 0; i < pathArray.length; i++) {
|
|
3290
|
+
const key = pathArray[i];
|
|
3291
|
+
if (i === pathArray.length - 1) {
|
|
3292
|
+
delete current[key];
|
|
3293
|
+
break;
|
|
3294
|
+
}
|
|
3295
|
+
if (current && ((current == null ? void 0 : current[key]) === void 0 || typeof (current == null ? void 0 : current[key]) !== "object" || (current == null ? void 0 : current[key]) === null)) {
|
|
3296
|
+
const nextKey = pathArray[i + 1];
|
|
3297
|
+
const isNextNumeric = /^\d+$/.test(nextKey);
|
|
3298
|
+
current[key] = isNextNumeric ? [] : {};
|
|
3299
|
+
}
|
|
3300
|
+
current = current == null ? void 0 : current[key];
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3303
|
+
return obj;
|
|
3304
|
+
}
|
|
3150
3305
|
const doNum = (n) => {
|
|
3151
3306
|
return formatNumber(n, { decimalPlaces: 4 });
|
|
3152
3307
|
};
|
|
@@ -3296,9 +3451,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3296
3451
|
detail = getDefaultElementGroupDetail();
|
|
3297
3452
|
}
|
|
3298
3453
|
const elem = {
|
|
3454
|
+
uuid: createUUID(),
|
|
3299
3455
|
...elementSize,
|
|
3300
3456
|
...baseElem,
|
|
3301
|
-
uuid: createUUID(),
|
|
3302
3457
|
type,
|
|
3303
3458
|
detail: {
|
|
3304
3459
|
...detail,
|
|
@@ -3443,33 +3598,29 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3443
3598
|
}
|
|
3444
3599
|
return { elements, from, to };
|
|
3445
3600
|
}
|
|
3446
|
-
function mergeElement(originElem, updateContent) {
|
|
3447
|
-
|
|
3448
|
-
const
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
if (
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
if (
|
|
3455
|
-
|
|
3456
|
-
originElem[commonKey] = {};
|
|
3457
|
-
}
|
|
3458
|
-
if (istype.json(originElem[commonKey])) {
|
|
3459
|
-
originElem[commonKey] = { ...originElem[commonKey], ...updateContent[commonKey] };
|
|
3460
|
-
}
|
|
3461
|
-
} else if (istype.array(updateContent[commonKey])) {
|
|
3462
|
-
if (!(originElem == null ? void 0 : originElem.hasOwnProperty(commonKey))) {
|
|
3463
|
-
originElem[commonKey] = [];
|
|
3464
|
-
}
|
|
3465
|
-
if (istype.array(originElem[commonKey])) {
|
|
3466
|
-
(_a = updateContent == null ? void 0 : updateContent[commonKey]) == null ? void 0 : _a.forEach((item, i2) => {
|
|
3467
|
-
originElem[commonKey][i2] = item;
|
|
3468
|
-
});
|
|
3469
|
-
originElem[commonKey] = [...originElem[commonKey], ...updateContent[commonKey]];
|
|
3470
|
-
}
|
|
3601
|
+
function mergeElement(originElem, updateContent, opts) {
|
|
3602
|
+
const updatedFlatten = toFlattenElement(updateContent);
|
|
3603
|
+
const ignoreKeys = ["uuid", "type"];
|
|
3604
|
+
const updatedKeys = Object.keys(updatedFlatten);
|
|
3605
|
+
updatedKeys.forEach((key) => {
|
|
3606
|
+
if (!ignoreKeys.includes(key)) {
|
|
3607
|
+
const value = updatedFlatten[key];
|
|
3608
|
+
del(originElem, key);
|
|
3609
|
+
if (value !== void 0) {
|
|
3610
|
+
set(originElem, key, value);
|
|
3471
3611
|
}
|
|
3472
3612
|
}
|
|
3613
|
+
});
|
|
3614
|
+
if ((opts == null ? void 0 : opts.strict) === true) {
|
|
3615
|
+
const originFlatten = toFlattenElement(originElem);
|
|
3616
|
+
const originKeys = Object.keys(originFlatten);
|
|
3617
|
+
originKeys.forEach((key) => {
|
|
3618
|
+
if (!ignoreKeys.includes(key)) {
|
|
3619
|
+
if (!updatedKeys.includes(key)) {
|
|
3620
|
+
del(originElem, key);
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
});
|
|
3473
3624
|
}
|
|
3474
3625
|
return originElem;
|
|
3475
3626
|
}
|
|
@@ -3496,7 +3647,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3496
3647
|
}
|
|
3497
3648
|
return targetElement;
|
|
3498
3649
|
}
|
|
3499
|
-
function updateElementInListByPosition(position, updateContent, elements) {
|
|
3650
|
+
function updateElementInListByPosition(position, updateContent, elements, opts) {
|
|
3500
3651
|
var _a;
|
|
3501
3652
|
const elem = findElementFromListByPosition(position, elements);
|
|
3502
3653
|
if (elem) {
|
|
@@ -3508,7 +3659,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3508
3659
|
});
|
|
3509
3660
|
}
|
|
3510
3661
|
}
|
|
3511
|
-
mergeElement(elem, updateContent);
|
|
3662
|
+
mergeElement(elem, updateContent, opts);
|
|
3512
3663
|
}
|
|
3513
3664
|
return elem;
|
|
3514
3665
|
}
|
|
@@ -3596,100 +3747,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3596
3747
|
};
|
|
3597
3748
|
return p;
|
|
3598
3749
|
}
|
|
3599
|
-
function modifyElement(data, options) {
|
|
3600
|
-
const { type } = options;
|
|
3601
|
-
const content = { ...options.content };
|
|
3602
|
-
if (type === "addElement") {
|
|
3603
|
-
const opts = options;
|
|
3604
|
-
const { element, position } = opts.content;
|
|
3605
|
-
if ((position == null ? void 0 : position.length) > 0) {
|
|
3606
|
-
insertElementToListByPosition(element, [...position], data.elements);
|
|
3607
|
-
} else {
|
|
3608
|
-
data.elements.push(element);
|
|
3609
|
-
}
|
|
3610
|
-
} else if (type === "deleteElement") {
|
|
3611
|
-
const opts = options;
|
|
3612
|
-
const { position } = opts.content;
|
|
3613
|
-
deleteElementInListByPosition(position, data.elements);
|
|
3614
|
-
} else if (type === "moveElement") {
|
|
3615
|
-
const opts = options;
|
|
3616
|
-
const { from, to } = opts.content;
|
|
3617
|
-
const movedResult = moveElementPosition(data.elements, { from, to });
|
|
3618
|
-
content.from = movedResult.from;
|
|
3619
|
-
content.to = movedResult.to;
|
|
3620
|
-
data.elements = movedResult.elements;
|
|
3621
|
-
} else if (type === "updateElement") {
|
|
3622
|
-
const opts = options;
|
|
3623
|
-
const { position, afterModifiedElement } = opts.content;
|
|
3624
|
-
updateElementInListByPosition(position, afterModifiedElement, data.elements);
|
|
3625
|
-
}
|
|
3626
|
-
return { data, content };
|
|
3627
|
-
}
|
|
3628
|
-
function _get(source, path, defaultValue = void 0) {
|
|
3629
|
-
const keyList = path.split(".");
|
|
3630
|
-
const result = keyList.reduce((obj, key) => {
|
|
3631
|
-
return Object(obj)[key];
|
|
3632
|
-
}, source);
|
|
3633
|
-
return result === void 0 ? defaultValue : result;
|
|
3634
|
-
}
|
|
3635
|
-
function _set(obj, path, value) {
|
|
3636
|
-
const keys = path.split(".");
|
|
3637
|
-
if (typeof obj !== "object") return obj;
|
|
3638
|
-
keys.reduce((o, k, i, _) => {
|
|
3639
|
-
if (i === _.length - 1) {
|
|
3640
|
-
o[k] = value;
|
|
3641
|
-
return null;
|
|
3642
|
-
} else if (k in o) {
|
|
3643
|
-
return o[k];
|
|
3644
|
-
} else {
|
|
3645
|
-
o[k] = /^[0-9]{1,}$/.test(_[i + 1]) ? [] : {};
|
|
3646
|
-
return o[k];
|
|
3647
|
-
}
|
|
3648
|
-
}, obj);
|
|
3649
|
-
return obj;
|
|
3650
|
-
}
|
|
3651
|
-
function getModifiedElement(target, originElement) {
|
|
3652
|
-
const modifiedElement = {};
|
|
3653
|
-
const pathList = [];
|
|
3654
|
-
const _walk = (t) => {
|
|
3655
|
-
if (istype.json(t)) {
|
|
3656
|
-
const keys = Object.keys(t);
|
|
3657
|
-
keys.forEach((key) => {
|
|
3658
|
-
pathList.push(key);
|
|
3659
|
-
if (istype.json(t[key]) || istype.array(t[key])) {
|
|
3660
|
-
_walk(t[key]);
|
|
3661
|
-
} else {
|
|
3662
|
-
const pathStr = pathList.join(".");
|
|
3663
|
-
if (pathStr !== "uuid") {
|
|
3664
|
-
const value = _get(originElement, pathStr);
|
|
3665
|
-
_set(modifiedElement, pathList.join("."), value);
|
|
3666
|
-
}
|
|
3667
|
-
}
|
|
3668
|
-
pathList.pop();
|
|
3669
|
-
});
|
|
3670
|
-
} else if (istype.array(t)) {
|
|
3671
|
-
t.forEach((index) => {
|
|
3672
|
-
pathList.push(index);
|
|
3673
|
-
if (istype.json(t[index]) || istype.array(t[index])) {
|
|
3674
|
-
_walk(t[index]);
|
|
3675
|
-
} else {
|
|
3676
|
-
const value = _get(originElement, pathList.join("."));
|
|
3677
|
-
_set(modifiedElement, pathList.join("."), value);
|
|
3678
|
-
}
|
|
3679
|
-
pathList.pop();
|
|
3680
|
-
});
|
|
3681
|
-
}
|
|
3682
|
-
};
|
|
3683
|
-
_walk(target);
|
|
3684
|
-
return modifiedElement;
|
|
3685
|
-
}
|
|
3686
3750
|
const baseFontFamilyList = ["-apple-system", '"system-ui"', ' "Segoe UI"', " Roboto", '"Helvetica Neue"', "Arial", '"Noto Sans"', " sans-serif"];
|
|
3687
3751
|
function enhanceFontFamliy(fontFamily2) {
|
|
3688
3752
|
return [fontFamily2, ...baseFontFamilyList].join(", ");
|
|
3689
3753
|
}
|
|
3690
3754
|
function flatElementSize(elemSize, opts) {
|
|
3691
3755
|
const { groupQueue } = opts;
|
|
3692
|
-
let { x: x2, y: y2
|
|
3756
|
+
let { x: x2, y: y2 } = elemSize;
|
|
3757
|
+
const { w: w2, h: h2, angle: angle2 = 0 } = elemSize;
|
|
3693
3758
|
let totalAngle = 0;
|
|
3694
3759
|
groupQueue.forEach((group) => {
|
|
3695
3760
|
x2 += group.x;
|
|
@@ -3917,6 +3982,132 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3917
3982
|
moveY
|
|
3918
3983
|
};
|
|
3919
3984
|
}
|
|
3985
|
+
function mergeLayout(originLayout, updateContent, opts) {
|
|
3986
|
+
const updatedFlatten = toFlattenLayout(updateContent);
|
|
3987
|
+
const ignoreKeys = [];
|
|
3988
|
+
const updatedKeys = Object.keys(updatedFlatten);
|
|
3989
|
+
updatedKeys.forEach((key) => {
|
|
3990
|
+
if (!ignoreKeys.includes(key)) {
|
|
3991
|
+
const value = updatedFlatten[key];
|
|
3992
|
+
del(originLayout, key);
|
|
3993
|
+
if (value !== void 0) {
|
|
3994
|
+
set(originLayout, key, value);
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
});
|
|
3998
|
+
if ((opts == null ? void 0 : opts.strict) === true) {
|
|
3999
|
+
const originFlatten = toFlattenLayout(originLayout);
|
|
4000
|
+
const originKeys = Object.keys(originFlatten);
|
|
4001
|
+
originKeys.forEach((key) => {
|
|
4002
|
+
if (!ignoreKeys.includes(key)) {
|
|
4003
|
+
if (!updatedKeys.includes(key)) {
|
|
4004
|
+
del(originLayout, key);
|
|
4005
|
+
}
|
|
4006
|
+
}
|
|
4007
|
+
});
|
|
4008
|
+
}
|
|
4009
|
+
return originLayout;
|
|
4010
|
+
}
|
|
4011
|
+
function mergeGlobal(originGlobal, updateContent, opts) {
|
|
4012
|
+
const updatedFlatten = toFlattenGlobal(updateContent);
|
|
4013
|
+
const ignoreKeys = [];
|
|
4014
|
+
const updatedKeys = Object.keys(updatedFlatten);
|
|
4015
|
+
updatedKeys.forEach((key) => {
|
|
4016
|
+
if (!ignoreKeys.includes(key)) {
|
|
4017
|
+
const value = updatedFlatten[key];
|
|
4018
|
+
del(originGlobal, key);
|
|
4019
|
+
if (value !== void 0) {
|
|
4020
|
+
set(originGlobal, key, value);
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4023
|
+
});
|
|
4024
|
+
if ((opts == null ? void 0 : opts.strict) === true) {
|
|
4025
|
+
const originFlatten = toFlattenGlobal(originGlobal);
|
|
4026
|
+
const originKeys = Object.keys(originFlatten);
|
|
4027
|
+
originKeys.forEach((key) => {
|
|
4028
|
+
if (!ignoreKeys.includes(key)) {
|
|
4029
|
+
if (!updatedKeys.includes(key)) {
|
|
4030
|
+
del(originGlobal, key);
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4033
|
+
});
|
|
4034
|
+
}
|
|
4035
|
+
return originGlobal;
|
|
4036
|
+
}
|
|
4037
|
+
function calcResultMovePosition(opts) {
|
|
4038
|
+
const from = [...opts.from];
|
|
4039
|
+
const to = [...opts.to];
|
|
4040
|
+
if (from.length === 0 || to.length === 0) {
|
|
4041
|
+
return null;
|
|
4042
|
+
}
|
|
4043
|
+
if (from.length <= to.length) {
|
|
4044
|
+
for (let i = 0; i < from.length; i++) {
|
|
4045
|
+
if (to[i] === from[i]) {
|
|
4046
|
+
if (i === from.length - 1) {
|
|
4047
|
+
return null;
|
|
4048
|
+
}
|
|
4049
|
+
continue;
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
let moveDirection = null;
|
|
4054
|
+
if (from.length >= 1 && to.length >= 1) {
|
|
4055
|
+
if (from.length <= to.length) {
|
|
4056
|
+
if (from.length === 1) {
|
|
4057
|
+
if (from[0] < to[0]) {
|
|
4058
|
+
moveDirection = "up-down";
|
|
4059
|
+
}
|
|
4060
|
+
} else {
|
|
4061
|
+
for (let i = 0; i < from.length; i++) {
|
|
4062
|
+
if (from[i] === to[i]) {
|
|
4063
|
+
if (from.length === from.length - 1) {
|
|
4064
|
+
moveDirection = "up-down";
|
|
4065
|
+
break;
|
|
4066
|
+
}
|
|
4067
|
+
} else {
|
|
4068
|
+
break;
|
|
4069
|
+
}
|
|
4070
|
+
}
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
if (from.length >= to.length) {
|
|
4074
|
+
if (to.length === 1) {
|
|
4075
|
+
if (to[0] < from[0]) {
|
|
4076
|
+
moveDirection = "down-up";
|
|
4077
|
+
}
|
|
4078
|
+
} else {
|
|
4079
|
+
for (let i = 0; i < to.length; i++) {
|
|
4080
|
+
if (i === to.length - 1 && to[i] < from[i]) {
|
|
4081
|
+
moveDirection = "down-up";
|
|
4082
|
+
}
|
|
4083
|
+
if (from[i] === to[i]) {
|
|
4084
|
+
continue;
|
|
4085
|
+
} else {
|
|
4086
|
+
break;
|
|
4087
|
+
}
|
|
4088
|
+
}
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
}
|
|
4092
|
+
const startEffectIndex = from.length - 1;
|
|
4093
|
+
const endEffectIndex = to.length - 1;
|
|
4094
|
+
if (moveDirection === "up-down" && startEffectIndex >= 0) {
|
|
4095
|
+
to[startEffectIndex] -= 1;
|
|
4096
|
+
} else if (moveDirection === "down-up" && endEffectIndex >= 0) {
|
|
4097
|
+
from[endEffectIndex] += 1;
|
|
4098
|
+
}
|
|
4099
|
+
return { from, to };
|
|
4100
|
+
}
|
|
4101
|
+
function calcRevertMovePosition(opts) {
|
|
4102
|
+
const result = calcResultMovePosition(opts);
|
|
4103
|
+
if (!result) {
|
|
4104
|
+
return result;
|
|
4105
|
+
}
|
|
4106
|
+
return {
|
|
4107
|
+
from: [...result.to],
|
|
4108
|
+
to: [...result.from]
|
|
4109
|
+
};
|
|
4110
|
+
}
|
|
3920
4111
|
function merge(target, source) {
|
|
3921
4112
|
const result = target;
|
|
3922
4113
|
for (const key in source) {
|
|
@@ -4105,6 +4296,93 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4105
4296
|
ip3e
|
|
4106
4297
|
};
|
|
4107
4298
|
}
|
|
4299
|
+
function unflatObject(flatObj) {
|
|
4300
|
+
const result = {};
|
|
4301
|
+
for (const [flatKey, value] of Object.entries(flatObj)) {
|
|
4302
|
+
const pathParts = parseKeyToPath(flatKey);
|
|
4303
|
+
buildNestedStructure(result, pathParts, value);
|
|
4304
|
+
}
|
|
4305
|
+
return result;
|
|
4306
|
+
}
|
|
4307
|
+
function parseKeyToPath(flatKey) {
|
|
4308
|
+
const regex = /([\w-]+)|\[(\d+)\]/g;
|
|
4309
|
+
const pathParts = [];
|
|
4310
|
+
let match;
|
|
4311
|
+
while ((match = regex.exec(flatKey)) !== null) {
|
|
4312
|
+
const prop = match[1] || match[2];
|
|
4313
|
+
if (prop) {
|
|
4314
|
+
pathParts.push(prop);
|
|
4315
|
+
}
|
|
4316
|
+
}
|
|
4317
|
+
return pathParts;
|
|
4318
|
+
}
|
|
4319
|
+
function buildNestedStructure(currentObj, pathParts, value) {
|
|
4320
|
+
let currentLevel = currentObj;
|
|
4321
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
4322
|
+
const part = pathParts[i];
|
|
4323
|
+
const isArrayPart = isArrayIndex(part);
|
|
4324
|
+
const isLast = i === pathParts.length - 1;
|
|
4325
|
+
try {
|
|
4326
|
+
if (isArrayPart) {
|
|
4327
|
+
validateArrayPath(currentLevel, part);
|
|
4328
|
+
} else {
|
|
4329
|
+
validateObjectPath(currentLevel, part);
|
|
4330
|
+
}
|
|
4331
|
+
} catch (e) {
|
|
4332
|
+
throw new Error(`Structure conflict at path '${pathParts.slice(0, i + 1).join(".")}': ${e.message}`);
|
|
4333
|
+
}
|
|
4334
|
+
if (isLast) {
|
|
4335
|
+
assignValue(currentLevel, part, value);
|
|
4336
|
+
} else {
|
|
4337
|
+
currentLevel = prepareNextLevel(currentLevel, part, pathParts[i + 1]);
|
|
4338
|
+
}
|
|
4339
|
+
}
|
|
4340
|
+
}
|
|
4341
|
+
function isArrayIndex(key) {
|
|
4342
|
+
return /^\d+$/.test(key);
|
|
4343
|
+
}
|
|
4344
|
+
function validateArrayPath(obj, index) {
|
|
4345
|
+
if (!Array.isArray(obj)) {
|
|
4346
|
+
throw new Error(`Expected array but found ${typeof obj}`);
|
|
4347
|
+
}
|
|
4348
|
+
const idx = Number(index);
|
|
4349
|
+
if (idx > obj.length) {
|
|
4350
|
+
obj.length = idx + 1;
|
|
4351
|
+
}
|
|
4352
|
+
}
|
|
4353
|
+
function validateObjectPath(obj, key) {
|
|
4354
|
+
if (Array.isArray(obj)) {
|
|
4355
|
+
throw new Error(`Cannot create object property '${key}' on array`);
|
|
4356
|
+
}
|
|
4357
|
+
if (typeof obj !== "object" || obj === null) {
|
|
4358
|
+
throw new Error(`Invalid structure for property '${key}'`);
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
function prepareNextLevel(current, part, nextPart) {
|
|
4362
|
+
const isNextArray = nextPart ? isArrayIndex(nextPart) : false;
|
|
4363
|
+
if (Array.isArray(current)) {
|
|
4364
|
+
const index = Number(part);
|
|
4365
|
+
if (!current[index]) {
|
|
4366
|
+
current[index] = isNextArray ? [] : {};
|
|
4367
|
+
}
|
|
4368
|
+
return current[index];
|
|
4369
|
+
}
|
|
4370
|
+
if (!current[part]) {
|
|
4371
|
+
current[part] = isNextArray ? [] : {};
|
|
4372
|
+
}
|
|
4373
|
+
return current[part];
|
|
4374
|
+
}
|
|
4375
|
+
function assignValue(target, key, value) {
|
|
4376
|
+
if (Array.isArray(target)) {
|
|
4377
|
+
const index = Number(key);
|
|
4378
|
+
if (index >= target.length) {
|
|
4379
|
+
target.length = index + 1;
|
|
4380
|
+
}
|
|
4381
|
+
target[index] = value;
|
|
4382
|
+
} else {
|
|
4383
|
+
target[key] = value;
|
|
4384
|
+
}
|
|
4385
|
+
}
|
|
4108
4386
|
exports.Context2D = Context2D;
|
|
4109
4387
|
exports.EventEmitter = EventEmitter;
|
|
4110
4388
|
exports.Store = Store;
|
|
@@ -4123,6 +4401,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4123
4401
|
exports.calcLayoutSizeController = calcLayoutSizeController;
|
|
4124
4402
|
exports.calcPointMoveElementInGroup = calcPointMoveElementInGroup;
|
|
4125
4403
|
exports.calcRadian = calcRadian;
|
|
4404
|
+
exports.calcResultMovePosition = calcResultMovePosition;
|
|
4405
|
+
exports.calcRevertMovePosition = calcRevertMovePosition;
|
|
4126
4406
|
exports.calcSpeed = calcSpeed;
|
|
4127
4407
|
exports.calcViewBoxSize = calcViewBoxSize;
|
|
4128
4408
|
exports.calcViewCenter = calcViewCenter;
|
|
@@ -4166,9 +4446,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4166
4446
|
exports.findElementsFromList = findElementsFromList;
|
|
4167
4447
|
exports.findElementsFromListByPositions = findElementsFromListByPositions;
|
|
4168
4448
|
exports.flatElementList = flatElementList;
|
|
4449
|
+
exports.flatObject = flatObject;
|
|
4169
4450
|
exports.formatNumber = formatNumber;
|
|
4170
4451
|
exports.generateHTML = generateHTML;
|
|
4171
4452
|
exports.generateSVGPath = generateSVGPath;
|
|
4453
|
+
exports.get = get;
|
|
4172
4454
|
exports.getCenterFromTwoPoints = getCenterFromTwoPoints;
|
|
4173
4455
|
exports.getDefaultElementDetailConfig = getDefaultElementDetailConfig;
|
|
4174
4456
|
exports.getDefaultElementRectDetail = getDefaultElementRectDetail;
|
|
@@ -4180,7 +4462,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4180
4462
|
exports.getElementVertexes = getElementVertexes;
|
|
4181
4463
|
exports.getGroupQueueByElementPosition = getGroupQueueByElementPosition;
|
|
4182
4464
|
exports.getGroupQueueFromList = getGroupQueueFromList;
|
|
4183
|
-
exports.getModifiedElement = getModifiedElement;
|
|
4184
4465
|
exports.getSelectedElementUUIDs = getSelectedElementUUIDs;
|
|
4185
4466
|
exports.getViewPointAtElement = getViewPointAtElement;
|
|
4186
4467
|
exports.getViewScaleInfoFromSnapshot = getViewScaleInfoFromSnapshot;
|
|
@@ -4204,9 +4485,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4204
4485
|
exports.matrixToAngle = matrixToAngle;
|
|
4205
4486
|
exports.matrixToRadian = matrixToRadian;
|
|
4206
4487
|
exports.merge = merge;
|
|
4488
|
+
exports.mergeElement = mergeElement;
|
|
4207
4489
|
exports.mergeElementAsset = mergeElementAsset;
|
|
4490
|
+
exports.mergeGlobal = mergeGlobal;
|
|
4208
4491
|
exports.mergeHexColorAlpha = mergeHexColorAlpha;
|
|
4209
|
-
exports.
|
|
4492
|
+
exports.mergeLayout = mergeLayout;
|
|
4210
4493
|
exports.moveElementPosition = moveElementPosition;
|
|
4211
4494
|
exports.omit = omit;
|
|
4212
4495
|
exports.originRectInfoToRangeRectInfo = originRectInfoToRangeRectInfo;
|
|
@@ -4223,10 +4506,16 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4223
4506
|
exports.rotatePoint = rotatePoint;
|
|
4224
4507
|
exports.rotatePointInGroup = rotatePointInGroup;
|
|
4225
4508
|
exports.rotateVertexes = rotateVertexes;
|
|
4509
|
+
exports.set = set;
|
|
4226
4510
|
exports.sortDataAsserts = sortDataAsserts;
|
|
4227
4511
|
exports.throttle = throttle;
|
|
4228
4512
|
exports.toColorHexNum = toColorHexNum;
|
|
4229
4513
|
exports.toColorHexStr = toColorHexStr;
|
|
4514
|
+
exports.toFlattenElement = toFlattenElement;
|
|
4515
|
+
exports.toFlattenGlobal = toFlattenGlobal;
|
|
4516
|
+
exports.toFlattenLayout = toFlattenLayout;
|
|
4517
|
+
exports.toPath = toPath;
|
|
4518
|
+
exports.unflatObject = unflatObject;
|
|
4230
4519
|
exports.ungroupElementsByPosition = ungroupElementsByPosition;
|
|
4231
4520
|
exports.updateElementInList = updateElementInList;
|
|
4232
4521
|
exports.updateElementInListByPosition = updateElementInListByPosition;
|