@idraw/util 0.4.0-beta.40 → 0.4.0-beta.41
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/tool/hash.d.ts +1 -0
- package/dist/esm/tool/hash.js +33 -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/tool/uuid.js +13 -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 +1 -1
- package/dist/esm/{lib → view}/element.js +12 -4
- 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 +459 -165
- 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 → tool}/uuid.d.ts +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
|
@@ -371,36 +371,49 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
371
371
|
}
|
|
372
372
|
return result;
|
|
373
373
|
}
|
|
374
|
+
function generate32Base36Hash(str) {
|
|
375
|
+
const hash256 = generate256BitHash(str);
|
|
376
|
+
return bigIntToBase36(hash256).padStart(32, "0").slice(0, 32);
|
|
377
|
+
}
|
|
378
|
+
function generate256BitHash(str) {
|
|
379
|
+
let h1 = 0xcbf29ce484222325n, h2 = 0x84222325cbf29ce4n;
|
|
380
|
+
let h3 = 0x1b3n * h1, h4 = 0x1000000n * h2;
|
|
381
|
+
const prime = 0x100000001b3n;
|
|
382
|
+
const chunkSize = 4096;
|
|
383
|
+
for (let i = 0; i < str.length; i += chunkSize) {
|
|
384
|
+
const chunk = str.slice(i, i + chunkSize);
|
|
385
|
+
for (let j = 0; j < chunk.length; j++) {
|
|
386
|
+
const code = BigInt(chunk.charCodeAt(j) + i + j);
|
|
387
|
+
h1 = (h1 ^ code) * prime;
|
|
388
|
+
h2 = (h2 ^ h1) * prime ^ h3;
|
|
389
|
+
h3 = (h3 ^ h2) * prime + h4;
|
|
390
|
+
h4 = (h4 ^ h3) * prime | 0x1234567890abcdefn;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return h1 << 192n | h2 << 128n | h3 << 64n | h4;
|
|
394
|
+
}
|
|
395
|
+
function bigIntToBase36(num) {
|
|
396
|
+
const chars = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
397
|
+
if (num === 0n) return "0";
|
|
398
|
+
let result = "";
|
|
399
|
+
while (num > 0n) {
|
|
400
|
+
const rem = num % 36n;
|
|
401
|
+
result = chars[Number(rem)] + result;
|
|
402
|
+
num = num / 36n;
|
|
403
|
+
}
|
|
404
|
+
return result;
|
|
405
|
+
}
|
|
374
406
|
function createUUID() {
|
|
375
407
|
function _createStr() {
|
|
376
408
|
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
377
409
|
}
|
|
378
410
|
return `${_createStr()}${_createStr()}-${_createStr()}-${_createStr()}-${_createStr()}-${_createStr()}${_createStr()}${_createStr()}`;
|
|
379
411
|
}
|
|
380
|
-
function limitHexStr(str) {
|
|
381
|
-
let count = 0;
|
|
382
|
-
for (let i = 0; i < str.length; i++) {
|
|
383
|
-
count += str.charCodeAt(i) * str.charCodeAt(i) * i * i;
|
|
384
|
-
}
|
|
385
|
-
return count.toString(16).substring(0, 4);
|
|
386
|
-
}
|
|
387
412
|
function createAssetId(assetStr) {
|
|
388
|
-
|
|
389
|
-
const mid = Math.floor(len / 2);
|
|
390
|
-
const start4 = assetStr.substring(0, 4).padEnd(4, "0");
|
|
391
|
-
const end4 = assetStr.substring(0, 4).padEnd(4, "0");
|
|
392
|
-
const str1 = limitHexStr(len.toString(16).padEnd(4, start4));
|
|
393
|
-
const str2 = limitHexStr(assetStr.substring(mid - 4, mid).padEnd(4, start4)).padEnd(4, "f");
|
|
394
|
-
const str3 = limitHexStr(assetStr.substring(mid - 8, mid - 4).padEnd(4, start4)).padEnd(4, "f");
|
|
395
|
-
const str4 = limitHexStr(assetStr.substring(mid - 12, mid - 8).padEnd(4, start4)).padEnd(4, "f");
|
|
396
|
-
const str5 = limitHexStr(assetStr.substring(mid - 16, mid - 12).padEnd(4, end4)).padEnd(4, "f");
|
|
397
|
-
const str6 = limitHexStr(assetStr.substring(mid, mid + 4).padEnd(4, end4)).padEnd(4, "f");
|
|
398
|
-
const str7 = limitHexStr(assetStr.substring(mid + 4, mid + 8).padEnd(4, end4)).padEnd(4, "f");
|
|
399
|
-
const str8 = limitHexStr(end4.padEnd(4, start4).padEnd(4, end4));
|
|
400
|
-
return `@assets/${str1}${str2}-${str3}-${str4}-${str5}-${str6}${str7}${str8}`;
|
|
413
|
+
return `@assets/${generate32Base36Hash(assetStr)}`;
|
|
401
414
|
}
|
|
402
415
|
function isAssetId(id) {
|
|
403
|
-
return /^@assets\/[0-9a-z
|
|
416
|
+
return /^@assets\/[0-9a-z-]{0,}$/.test(`${id}`);
|
|
404
417
|
}
|
|
405
418
|
function deepClone(target) {
|
|
406
419
|
function _clone(t) {
|
|
@@ -814,20 +827,20 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
814
827
|
}
|
|
815
828
|
function box(detail = {}) {
|
|
816
829
|
const { borderColor, borderRadius: borderRadius2, borderWidth: borderWidth2 } = detail;
|
|
817
|
-
if (
|
|
830
|
+
if (Object.prototype.hasOwnProperty.call(detail, "borderColor") && !is.color(borderColor)) {
|
|
818
831
|
return false;
|
|
819
832
|
}
|
|
820
|
-
if (
|
|
833
|
+
if (Object.prototype.hasOwnProperty.call(detail, "borderRadius") && !is.number(borderRadius2)) {
|
|
821
834
|
return false;
|
|
822
835
|
}
|
|
823
|
-
if (
|
|
836
|
+
if (Object.prototype.hasOwnProperty.call(detail, "borderWidth") && !is.number(borderWidth2)) {
|
|
824
837
|
return false;
|
|
825
838
|
}
|
|
826
839
|
return true;
|
|
827
840
|
}
|
|
828
841
|
function rectDesc(detail) {
|
|
829
842
|
const { background } = detail;
|
|
830
|
-
if (
|
|
843
|
+
if (Object.prototype.hasOwnProperty.call(detail, "background") && !is.color(background)) {
|
|
831
844
|
return false;
|
|
832
845
|
}
|
|
833
846
|
if (!box(detail)) {
|
|
@@ -837,13 +850,13 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
837
850
|
}
|
|
838
851
|
function circleDesc(detail) {
|
|
839
852
|
const { background, borderColor, borderWidth: borderWidth2 } = detail;
|
|
840
|
-
if (
|
|
853
|
+
if (Object.prototype.hasOwnProperty.call(detail, "background") && !is.color(background)) {
|
|
841
854
|
return false;
|
|
842
855
|
}
|
|
843
|
-
if (
|
|
856
|
+
if (Object.prototype.hasOwnProperty.call(detail, "borderColor") && !is.color(borderColor)) {
|
|
844
857
|
return false;
|
|
845
858
|
}
|
|
846
|
-
if (
|
|
859
|
+
if (Object.prototype.hasOwnProperty.call(detail, "borderWidth") && !is.number(borderWidth2)) {
|
|
847
860
|
return false;
|
|
848
861
|
}
|
|
849
862
|
return true;
|
|
@@ -880,25 +893,25 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
880
893
|
if (!is.fontSize(fontSize2)) {
|
|
881
894
|
return false;
|
|
882
895
|
}
|
|
883
|
-
if (
|
|
896
|
+
if (Object.prototype.hasOwnProperty.call(detail, "background") && !is.color(background)) {
|
|
884
897
|
return false;
|
|
885
898
|
}
|
|
886
|
-
if (
|
|
899
|
+
if (Object.prototype.hasOwnProperty.call(detail, "fontWeight") && !is.fontWeight(fontWeight2)) {
|
|
887
900
|
return false;
|
|
888
901
|
}
|
|
889
|
-
if (
|
|
902
|
+
if (Object.prototype.hasOwnProperty.call(detail, "lineHeight") && !is.lineHeight(lineHeight2)) {
|
|
890
903
|
return false;
|
|
891
904
|
}
|
|
892
|
-
if (
|
|
905
|
+
if (Object.prototype.hasOwnProperty.call(detail, "fontFamily") && !is.fontFamily(fontFamily2)) {
|
|
893
906
|
return false;
|
|
894
907
|
}
|
|
895
|
-
if (
|
|
908
|
+
if (Object.prototype.hasOwnProperty.call(detail, "textAlign") && !is.textAlign(textAlign2)) {
|
|
896
909
|
return false;
|
|
897
910
|
}
|
|
898
|
-
if (
|
|
911
|
+
if (Object.prototype.hasOwnProperty.call(detail, "strokeWidth") && !is.strokeWidth(strokeWidth2)) {
|
|
899
912
|
return false;
|
|
900
913
|
}
|
|
901
|
-
if (
|
|
914
|
+
if (Object.prototype.hasOwnProperty.call(detail, "strokeColor") && !is.color(strokeColor)) {
|
|
902
915
|
return false;
|
|
903
916
|
}
|
|
904
917
|
if (!box(detail)) {
|
|
@@ -1815,7 +1828,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1815
1828
|
return ctxSize;
|
|
1816
1829
|
}
|
|
1817
1830
|
function calcElementsViewInfo(elements, prevViewSize, options) {
|
|
1818
|
-
const contextSize = calcElementsContextSize(elements, {
|
|
1831
|
+
const contextSize = calcElementsContextSize(elements, {
|
|
1832
|
+
viewWidth: prevViewSize.width,
|
|
1833
|
+
viewHeight: prevViewSize.height,
|
|
1834
|
+
extend: options == null ? void 0 : options.extend
|
|
1835
|
+
});
|
|
1819
1836
|
if ((options == null ? void 0 : options.extend) === true) {
|
|
1820
1837
|
contextSize.contextWidth = Math.max(contextSize.contextWidth, prevViewSize.contextWidth);
|
|
1821
1838
|
contextSize.contextHeight = Math.max(contextSize.contextHeight, prevViewSize.contextHeight);
|
|
@@ -1999,7 +2016,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
1999
2016
|
for (let i = 0; i < position.length; i++) {
|
|
2000
2017
|
const pos = position[i];
|
|
2001
2018
|
const item = tempList[pos];
|
|
2002
|
-
if (i < position.length - 1 && item.type === "group") {
|
|
2019
|
+
if (i < position.length - 1 && (item == null ? void 0 : item.type) === "group") {
|
|
2003
2020
|
tempList = item.detail.children;
|
|
2004
2021
|
} else if (i === position.length - 1) {
|
|
2005
2022
|
result = item;
|
|
@@ -2576,15 +2593,38 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2576
2593
|
const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: totalAngle });
|
|
2577
2594
|
const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: totalAngle });
|
|
2578
2595
|
const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: totalAngle });
|
|
2579
|
-
const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, {
|
|
2596
|
+
const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, {
|
|
2597
|
+
size: ctrlSize,
|
|
2598
|
+
angle: totalAngle
|
|
2599
|
+
});
|
|
2580
2600
|
const topLeftVertexes = calcElementVertexes(topLeftSize);
|
|
2581
2601
|
const topRightVertexes = calcElementVertexes(topRightSize);
|
|
2582
2602
|
const bottomLeftVertexes = calcElementVertexes(bottomLeftSize);
|
|
2583
2603
|
const bottomRightVertexes = calcElementVertexes(bottomRightSize);
|
|
2584
|
-
const topVertexes = [
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2604
|
+
const topVertexes = [
|
|
2605
|
+
topLeftVertexes[1],
|
|
2606
|
+
topRightVertexes[0],
|
|
2607
|
+
topRightVertexes[3],
|
|
2608
|
+
topLeftVertexes[2]
|
|
2609
|
+
];
|
|
2610
|
+
const rightVertexes = [
|
|
2611
|
+
topRightVertexes[3],
|
|
2612
|
+
topRightVertexes[2],
|
|
2613
|
+
bottomRightVertexes[1],
|
|
2614
|
+
bottomRightVertexes[0]
|
|
2615
|
+
];
|
|
2616
|
+
const bottomVertexes = [
|
|
2617
|
+
bottomLeftVertexes[1],
|
|
2618
|
+
bottomRightVertexes[0],
|
|
2619
|
+
bottomRightVertexes[3],
|
|
2620
|
+
bottomLeftVertexes[2]
|
|
2621
|
+
];
|
|
2622
|
+
const leftVertexes = [
|
|
2623
|
+
topLeftVertexes[3],
|
|
2624
|
+
topLeftVertexes[2],
|
|
2625
|
+
bottomLeftVertexes[1],
|
|
2626
|
+
bottomLeftVertexes[0]
|
|
2627
|
+
];
|
|
2588
2628
|
const topMiddleVertexes = calcElementVertexes(topMiddleSize);
|
|
2589
2629
|
const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
|
|
2590
2630
|
const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
|
|
@@ -2706,10 +2746,30 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2706
2746
|
const topRightVertexes = calcElementVertexes(topRightSize);
|
|
2707
2747
|
const bottomLeftVertexes = calcElementVertexes(bottomLeftSize);
|
|
2708
2748
|
const bottomRightVertexes = calcElementVertexes(bottomRightSize);
|
|
2709
|
-
const topVertexes = [
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2749
|
+
const topVertexes = [
|
|
2750
|
+
topLeftVertexes[1],
|
|
2751
|
+
topRightVertexes[0],
|
|
2752
|
+
topRightVertexes[3],
|
|
2753
|
+
topLeftVertexes[2]
|
|
2754
|
+
];
|
|
2755
|
+
const rightVertexes = [
|
|
2756
|
+
topRightVertexes[3],
|
|
2757
|
+
topRightVertexes[2],
|
|
2758
|
+
bottomRightVertexes[1],
|
|
2759
|
+
bottomRightVertexes[0]
|
|
2760
|
+
];
|
|
2761
|
+
const bottomVertexes = [
|
|
2762
|
+
bottomLeftVertexes[1],
|
|
2763
|
+
bottomRightVertexes[0],
|
|
2764
|
+
bottomRightVertexes[3],
|
|
2765
|
+
bottomLeftVertexes[2]
|
|
2766
|
+
];
|
|
2767
|
+
const leftVertexes = [
|
|
2768
|
+
topLeftVertexes[3],
|
|
2769
|
+
topLeftVertexes[2],
|
|
2770
|
+
bottomLeftVertexes[1],
|
|
2771
|
+
bottomLeftVertexes[0]
|
|
2772
|
+
];
|
|
2713
2773
|
const topMiddleVertexes = calcElementVertexes(topMiddleSize);
|
|
2714
2774
|
const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
|
|
2715
2775
|
const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
|
|
@@ -2945,7 +3005,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
2945
3005
|
}
|
|
2946
3006
|
function attrString(attrs2) {
|
|
2947
3007
|
const buff = [];
|
|
2948
|
-
for (
|
|
3008
|
+
for (const key in attrs2) {
|
|
2949
3009
|
buff.push(key + '="' + attrs2[key] + '"');
|
|
2950
3010
|
}
|
|
2951
3011
|
if (!buff.length) {
|
|
@@ -3147,6 +3207,106 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3147
3207
|
radiusList
|
|
3148
3208
|
};
|
|
3149
3209
|
}
|
|
3210
|
+
function flattenObject(obj, parentKey = "", result = {}, opts) {
|
|
3211
|
+
Object.keys(obj).forEach((key) => {
|
|
3212
|
+
var _a;
|
|
3213
|
+
const currentKey = parentKey ? `${parentKey}${isArrayIndex$1(key) ? `[${key}]` : `.${key}`}` : key;
|
|
3214
|
+
if (!((_a = opts == null ? void 0 : opts.ignorePaths) == null ? void 0 : _a.includes(currentKey))) {
|
|
3215
|
+
const value = obj[key];
|
|
3216
|
+
if (isFlattenable(value)) {
|
|
3217
|
+
flattenObject(value, Array.isArray(value) ? currentKey : currentKey, result, opts);
|
|
3218
|
+
} else {
|
|
3219
|
+
result[currentKey] = value;
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
});
|
|
3223
|
+
return result;
|
|
3224
|
+
}
|
|
3225
|
+
function isFlattenable(value) {
|
|
3226
|
+
return typeof value === "object" && value !== null && !(value instanceof Date) || Array.isArray(value);
|
|
3227
|
+
}
|
|
3228
|
+
function isArrayIndex$1(key) {
|
|
3229
|
+
return /^\d+$/.test(key) && !isNaN(Number(key));
|
|
3230
|
+
}
|
|
3231
|
+
function flatObject(obj, opts) {
|
|
3232
|
+
if (typeof obj !== "object" || obj === null) {
|
|
3233
|
+
return { "": obj };
|
|
3234
|
+
}
|
|
3235
|
+
return flattenObject(obj, "", {}, opts);
|
|
3236
|
+
}
|
|
3237
|
+
function toFlattenElement(elem) {
|
|
3238
|
+
return flatObject(elem, { ignorePaths: ["detail.children"] });
|
|
3239
|
+
}
|
|
3240
|
+
function toFlattenLayout(layout) {
|
|
3241
|
+
return flatObject(layout);
|
|
3242
|
+
}
|
|
3243
|
+
function toFlattenGlobal(global) {
|
|
3244
|
+
return flatObject(global);
|
|
3245
|
+
}
|
|
3246
|
+
function toPath(path) {
|
|
3247
|
+
if (Array.isArray(path)) return [...path];
|
|
3248
|
+
return path.split(/\.|\[|\]/).filter((key) => key !== "");
|
|
3249
|
+
}
|
|
3250
|
+
function get(obj, path, defaultValue) {
|
|
3251
|
+
if (!path) {
|
|
3252
|
+
return void 0;
|
|
3253
|
+
}
|
|
3254
|
+
const pathArray = toPath(path);
|
|
3255
|
+
let current = obj;
|
|
3256
|
+
for (const key of pathArray) {
|
|
3257
|
+
if (current === null || current === void 0) {
|
|
3258
|
+
return defaultValue;
|
|
3259
|
+
}
|
|
3260
|
+
current = current[key];
|
|
3261
|
+
}
|
|
3262
|
+
return current !== void 0 ? current : defaultValue;
|
|
3263
|
+
}
|
|
3264
|
+
function set(obj, path, value) {
|
|
3265
|
+
const pathArray = toPath(path);
|
|
3266
|
+
if (pathArray.length === 0) {
|
|
3267
|
+
return obj;
|
|
3268
|
+
}
|
|
3269
|
+
let current = obj;
|
|
3270
|
+
if (current) {
|
|
3271
|
+
for (let i = 0; i < pathArray.length; i++) {
|
|
3272
|
+
const key = pathArray[i];
|
|
3273
|
+
if (i === pathArray.length - 1) {
|
|
3274
|
+
current[key] = value;
|
|
3275
|
+
break;
|
|
3276
|
+
}
|
|
3277
|
+
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)) {
|
|
3278
|
+
const nextKey = pathArray[i + 1];
|
|
3279
|
+
const isNextNumeric = /^\d+$/.test(nextKey);
|
|
3280
|
+
current[key] = isNextNumeric ? [] : {};
|
|
3281
|
+
}
|
|
3282
|
+
current = current == null ? void 0 : current[key];
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
return obj;
|
|
3286
|
+
}
|
|
3287
|
+
function del(obj, path) {
|
|
3288
|
+
const pathArray = toPath(path);
|
|
3289
|
+
if (pathArray.length === 0) {
|
|
3290
|
+
return obj;
|
|
3291
|
+
}
|
|
3292
|
+
let current = obj;
|
|
3293
|
+
if (current) {
|
|
3294
|
+
for (let i = 0; i < pathArray.length; i++) {
|
|
3295
|
+
const key = pathArray[i];
|
|
3296
|
+
if (i === pathArray.length - 1) {
|
|
3297
|
+
delete current[key];
|
|
3298
|
+
break;
|
|
3299
|
+
}
|
|
3300
|
+
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)) {
|
|
3301
|
+
const nextKey = pathArray[i + 1];
|
|
3302
|
+
const isNextNumeric = /^\d+$/.test(nextKey);
|
|
3303
|
+
current[key] = isNextNumeric ? [] : {};
|
|
3304
|
+
}
|
|
3305
|
+
current = current == null ? void 0 : current[key];
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
return obj;
|
|
3309
|
+
}
|
|
3150
3310
|
const doNum = (n) => {
|
|
3151
3311
|
return formatNumber(n, { decimalPlaces: 4 });
|
|
3152
3312
|
};
|
|
@@ -3296,9 +3456,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3296
3456
|
detail = getDefaultElementGroupDetail();
|
|
3297
3457
|
}
|
|
3298
3458
|
const elem = {
|
|
3459
|
+
uuid: createUUID(),
|
|
3299
3460
|
...elementSize,
|
|
3300
3461
|
...baseElem,
|
|
3301
|
-
uuid: createUUID(),
|
|
3302
3462
|
type,
|
|
3303
3463
|
detail: {
|
|
3304
3464
|
...detail,
|
|
@@ -3443,33 +3603,29 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3443
3603
|
}
|
|
3444
3604
|
return { elements, from, to };
|
|
3445
3605
|
}
|
|
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
|
-
}
|
|
3606
|
+
function mergeElement(originElem, updateContent, opts) {
|
|
3607
|
+
const updatedFlatten = toFlattenElement(updateContent);
|
|
3608
|
+
const ignoreKeys = ["uuid", "type"];
|
|
3609
|
+
const updatedKeys = Object.keys(updatedFlatten);
|
|
3610
|
+
updatedKeys.forEach((key) => {
|
|
3611
|
+
if (!ignoreKeys.includes(key)) {
|
|
3612
|
+
const value = updatedFlatten[key];
|
|
3613
|
+
del(originElem, key);
|
|
3614
|
+
if (value !== void 0) {
|
|
3615
|
+
set(originElem, key, value);
|
|
3471
3616
|
}
|
|
3472
3617
|
}
|
|
3618
|
+
});
|
|
3619
|
+
if ((opts == null ? void 0 : opts.strict) === true) {
|
|
3620
|
+
const originFlatten = toFlattenElement(originElem);
|
|
3621
|
+
const originKeys = Object.keys(originFlatten);
|
|
3622
|
+
originKeys.forEach((key) => {
|
|
3623
|
+
if (!ignoreKeys.includes(key)) {
|
|
3624
|
+
if (!updatedKeys.includes(key)) {
|
|
3625
|
+
del(originElem, key);
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
});
|
|
3473
3629
|
}
|
|
3474
3630
|
return originElem;
|
|
3475
3631
|
}
|
|
@@ -3496,7 +3652,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3496
3652
|
}
|
|
3497
3653
|
return targetElement;
|
|
3498
3654
|
}
|
|
3499
|
-
function updateElementInListByPosition(position, updateContent, elements) {
|
|
3655
|
+
function updateElementInListByPosition(position, updateContent, elements, opts) {
|
|
3500
3656
|
var _a;
|
|
3501
3657
|
const elem = findElementFromListByPosition(position, elements);
|
|
3502
3658
|
if (elem) {
|
|
@@ -3508,7 +3664,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3508
3664
|
});
|
|
3509
3665
|
}
|
|
3510
3666
|
}
|
|
3511
|
-
mergeElement(elem, updateContent);
|
|
3667
|
+
mergeElement(elem, updateContent, opts);
|
|
3512
3668
|
}
|
|
3513
3669
|
return elem;
|
|
3514
3670
|
}
|
|
@@ -3596,100 +3752,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3596
3752
|
};
|
|
3597
3753
|
return p;
|
|
3598
3754
|
}
|
|
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
3755
|
const baseFontFamilyList = ["-apple-system", '"system-ui"', ' "Segoe UI"', " Roboto", '"Helvetica Neue"', "Arial", '"Noto Sans"', " sans-serif"];
|
|
3687
3756
|
function enhanceFontFamliy(fontFamily2) {
|
|
3688
3757
|
return [fontFamily2, ...baseFontFamilyList].join(", ");
|
|
3689
3758
|
}
|
|
3690
3759
|
function flatElementSize(elemSize, opts) {
|
|
3691
3760
|
const { groupQueue } = opts;
|
|
3692
|
-
let { x: x2, y: y2
|
|
3761
|
+
let { x: x2, y: y2 } = elemSize;
|
|
3762
|
+
const { w: w2, h: h2, angle: angle2 = 0 } = elemSize;
|
|
3693
3763
|
let totalAngle = 0;
|
|
3694
3764
|
groupQueue.forEach((group) => {
|
|
3695
3765
|
x2 += group.x;
|
|
@@ -3917,6 +3987,132 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
3917
3987
|
moveY
|
|
3918
3988
|
};
|
|
3919
3989
|
}
|
|
3990
|
+
function mergeLayout(originLayout, updateContent, opts) {
|
|
3991
|
+
const updatedFlatten = toFlattenLayout(updateContent);
|
|
3992
|
+
const ignoreKeys = [];
|
|
3993
|
+
const updatedKeys = Object.keys(updatedFlatten);
|
|
3994
|
+
updatedKeys.forEach((key) => {
|
|
3995
|
+
if (!ignoreKeys.includes(key)) {
|
|
3996
|
+
const value = updatedFlatten[key];
|
|
3997
|
+
del(originLayout, key);
|
|
3998
|
+
if (value !== void 0) {
|
|
3999
|
+
set(originLayout, key, value);
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
});
|
|
4003
|
+
if ((opts == null ? void 0 : opts.strict) === true) {
|
|
4004
|
+
const originFlatten = toFlattenLayout(originLayout);
|
|
4005
|
+
const originKeys = Object.keys(originFlatten);
|
|
4006
|
+
originKeys.forEach((key) => {
|
|
4007
|
+
if (!ignoreKeys.includes(key)) {
|
|
4008
|
+
if (!updatedKeys.includes(key)) {
|
|
4009
|
+
del(originLayout, key);
|
|
4010
|
+
}
|
|
4011
|
+
}
|
|
4012
|
+
});
|
|
4013
|
+
}
|
|
4014
|
+
return originLayout;
|
|
4015
|
+
}
|
|
4016
|
+
function mergeGlobal(originGlobal, updateContent, opts) {
|
|
4017
|
+
const updatedFlatten = toFlattenGlobal(updateContent);
|
|
4018
|
+
const ignoreKeys = [];
|
|
4019
|
+
const updatedKeys = Object.keys(updatedFlatten);
|
|
4020
|
+
updatedKeys.forEach((key) => {
|
|
4021
|
+
if (!ignoreKeys.includes(key)) {
|
|
4022
|
+
const value = updatedFlatten[key];
|
|
4023
|
+
del(originGlobal, key);
|
|
4024
|
+
if (value !== void 0) {
|
|
4025
|
+
set(originGlobal, key, value);
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
});
|
|
4029
|
+
if ((opts == null ? void 0 : opts.strict) === true) {
|
|
4030
|
+
const originFlatten = toFlattenGlobal(originGlobal);
|
|
4031
|
+
const originKeys = Object.keys(originFlatten);
|
|
4032
|
+
originKeys.forEach((key) => {
|
|
4033
|
+
if (!ignoreKeys.includes(key)) {
|
|
4034
|
+
if (!updatedKeys.includes(key)) {
|
|
4035
|
+
del(originGlobal, key);
|
|
4036
|
+
}
|
|
4037
|
+
}
|
|
4038
|
+
});
|
|
4039
|
+
}
|
|
4040
|
+
return originGlobal;
|
|
4041
|
+
}
|
|
4042
|
+
function calcResultMovePosition(opts) {
|
|
4043
|
+
const from = [...opts.from];
|
|
4044
|
+
const to = [...opts.to];
|
|
4045
|
+
if (from.length === 0 || to.length === 0) {
|
|
4046
|
+
return null;
|
|
4047
|
+
}
|
|
4048
|
+
if (from.length <= to.length) {
|
|
4049
|
+
for (let i = 0; i < from.length; i++) {
|
|
4050
|
+
if (to[i] === from[i]) {
|
|
4051
|
+
if (i === from.length - 1) {
|
|
4052
|
+
return null;
|
|
4053
|
+
}
|
|
4054
|
+
continue;
|
|
4055
|
+
}
|
|
4056
|
+
}
|
|
4057
|
+
}
|
|
4058
|
+
let moveDirection = null;
|
|
4059
|
+
if (from.length >= 1 && to.length >= 1) {
|
|
4060
|
+
if (from.length <= to.length) {
|
|
4061
|
+
if (from.length === 1) {
|
|
4062
|
+
if (from[0] < to[0]) {
|
|
4063
|
+
moveDirection = "up-down";
|
|
4064
|
+
}
|
|
4065
|
+
} else {
|
|
4066
|
+
for (let i = 0; i < from.length; i++) {
|
|
4067
|
+
if (from[i] === to[i]) {
|
|
4068
|
+
if (from.length === from.length - 1) {
|
|
4069
|
+
moveDirection = "up-down";
|
|
4070
|
+
break;
|
|
4071
|
+
}
|
|
4072
|
+
} else {
|
|
4073
|
+
break;
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
}
|
|
4077
|
+
}
|
|
4078
|
+
if (from.length >= to.length) {
|
|
4079
|
+
if (to.length === 1) {
|
|
4080
|
+
if (to[0] < from[0]) {
|
|
4081
|
+
moveDirection = "down-up";
|
|
4082
|
+
}
|
|
4083
|
+
} else {
|
|
4084
|
+
for (let i = 0; i < to.length; i++) {
|
|
4085
|
+
if (i === to.length - 1 && to[i] < from[i]) {
|
|
4086
|
+
moveDirection = "down-up";
|
|
4087
|
+
}
|
|
4088
|
+
if (from[i] === to[i]) {
|
|
4089
|
+
continue;
|
|
4090
|
+
} else {
|
|
4091
|
+
break;
|
|
4092
|
+
}
|
|
4093
|
+
}
|
|
4094
|
+
}
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
const startEffectIndex = from.length - 1;
|
|
4098
|
+
const endEffectIndex = to.length - 1;
|
|
4099
|
+
if (moveDirection === "up-down" && startEffectIndex >= 0) {
|
|
4100
|
+
to[startEffectIndex] -= 1;
|
|
4101
|
+
} else if (moveDirection === "down-up" && endEffectIndex >= 0) {
|
|
4102
|
+
from[endEffectIndex] += 1;
|
|
4103
|
+
}
|
|
4104
|
+
return { from, to };
|
|
4105
|
+
}
|
|
4106
|
+
function calcRevertMovePosition(opts) {
|
|
4107
|
+
const result = calcResultMovePosition(opts);
|
|
4108
|
+
if (!result) {
|
|
4109
|
+
return result;
|
|
4110
|
+
}
|
|
4111
|
+
return {
|
|
4112
|
+
from: [...result.to],
|
|
4113
|
+
to: [...result.from]
|
|
4114
|
+
};
|
|
4115
|
+
}
|
|
3920
4116
|
function merge(target, source) {
|
|
3921
4117
|
const result = target;
|
|
3922
4118
|
for (const key in source) {
|
|
@@ -4105,6 +4301,93 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4105
4301
|
ip3e
|
|
4106
4302
|
};
|
|
4107
4303
|
}
|
|
4304
|
+
function unflatObject(flatObj) {
|
|
4305
|
+
const result = {};
|
|
4306
|
+
for (const [flatKey, value] of Object.entries(flatObj)) {
|
|
4307
|
+
const pathParts = parseKeyToPath(flatKey);
|
|
4308
|
+
buildNestedStructure(result, pathParts, value);
|
|
4309
|
+
}
|
|
4310
|
+
return result;
|
|
4311
|
+
}
|
|
4312
|
+
function parseKeyToPath(flatKey) {
|
|
4313
|
+
const regex = /([\w-]+)|\[(\d+)\]/g;
|
|
4314
|
+
const pathParts = [];
|
|
4315
|
+
let match;
|
|
4316
|
+
while ((match = regex.exec(flatKey)) !== null) {
|
|
4317
|
+
const prop = match[1] || match[2];
|
|
4318
|
+
if (prop) {
|
|
4319
|
+
pathParts.push(prop);
|
|
4320
|
+
}
|
|
4321
|
+
}
|
|
4322
|
+
return pathParts;
|
|
4323
|
+
}
|
|
4324
|
+
function buildNestedStructure(currentObj, pathParts, value) {
|
|
4325
|
+
let currentLevel = currentObj;
|
|
4326
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
4327
|
+
const part = pathParts[i];
|
|
4328
|
+
const isArrayPart = isArrayIndex(part);
|
|
4329
|
+
const isLast = i === pathParts.length - 1;
|
|
4330
|
+
try {
|
|
4331
|
+
if (isArrayPart) {
|
|
4332
|
+
validateArrayPath(currentLevel, part);
|
|
4333
|
+
} else {
|
|
4334
|
+
validateObjectPath(currentLevel, part);
|
|
4335
|
+
}
|
|
4336
|
+
} catch (e) {
|
|
4337
|
+
throw new Error(`Structure conflict at path '${pathParts.slice(0, i + 1).join(".")}': ${e.message}`);
|
|
4338
|
+
}
|
|
4339
|
+
if (isLast) {
|
|
4340
|
+
assignValue(currentLevel, part, value);
|
|
4341
|
+
} else {
|
|
4342
|
+
currentLevel = prepareNextLevel(currentLevel, part, pathParts[i + 1]);
|
|
4343
|
+
}
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
function isArrayIndex(key) {
|
|
4347
|
+
return /^\d+$/.test(key);
|
|
4348
|
+
}
|
|
4349
|
+
function validateArrayPath(obj, index) {
|
|
4350
|
+
if (!Array.isArray(obj)) {
|
|
4351
|
+
throw new Error(`Expected array but found ${typeof obj}`);
|
|
4352
|
+
}
|
|
4353
|
+
const idx = Number(index);
|
|
4354
|
+
if (idx > obj.length) {
|
|
4355
|
+
obj.length = idx + 1;
|
|
4356
|
+
}
|
|
4357
|
+
}
|
|
4358
|
+
function validateObjectPath(obj, key) {
|
|
4359
|
+
if (Array.isArray(obj)) {
|
|
4360
|
+
throw new Error(`Cannot create object property '${key}' on array`);
|
|
4361
|
+
}
|
|
4362
|
+
if (typeof obj !== "object" || obj === null) {
|
|
4363
|
+
throw new Error(`Invalid structure for property '${key}'`);
|
|
4364
|
+
}
|
|
4365
|
+
}
|
|
4366
|
+
function prepareNextLevel(current, part, nextPart) {
|
|
4367
|
+
const isNextArray = nextPart ? isArrayIndex(nextPart) : false;
|
|
4368
|
+
if (Array.isArray(current)) {
|
|
4369
|
+
const index = Number(part);
|
|
4370
|
+
if (!current[index]) {
|
|
4371
|
+
current[index] = isNextArray ? [] : {};
|
|
4372
|
+
}
|
|
4373
|
+
return current[index];
|
|
4374
|
+
}
|
|
4375
|
+
if (!current[part]) {
|
|
4376
|
+
current[part] = isNextArray ? [] : {};
|
|
4377
|
+
}
|
|
4378
|
+
return current[part];
|
|
4379
|
+
}
|
|
4380
|
+
function assignValue(target, key, value) {
|
|
4381
|
+
if (Array.isArray(target)) {
|
|
4382
|
+
const index = Number(key);
|
|
4383
|
+
if (index >= target.length) {
|
|
4384
|
+
target.length = index + 1;
|
|
4385
|
+
}
|
|
4386
|
+
target[index] = value;
|
|
4387
|
+
} else {
|
|
4388
|
+
target[key] = value;
|
|
4389
|
+
}
|
|
4390
|
+
}
|
|
4108
4391
|
exports.Context2D = Context2D;
|
|
4109
4392
|
exports.EventEmitter = EventEmitter;
|
|
4110
4393
|
exports.Store = Store;
|
|
@@ -4123,6 +4406,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4123
4406
|
exports.calcLayoutSizeController = calcLayoutSizeController;
|
|
4124
4407
|
exports.calcPointMoveElementInGroup = calcPointMoveElementInGroup;
|
|
4125
4408
|
exports.calcRadian = calcRadian;
|
|
4409
|
+
exports.calcResultMovePosition = calcResultMovePosition;
|
|
4410
|
+
exports.calcRevertMovePosition = calcRevertMovePosition;
|
|
4126
4411
|
exports.calcSpeed = calcSpeed;
|
|
4127
4412
|
exports.calcViewBoxSize = calcViewBoxSize;
|
|
4128
4413
|
exports.calcViewCenter = calcViewCenter;
|
|
@@ -4166,9 +4451,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4166
4451
|
exports.findElementsFromList = findElementsFromList;
|
|
4167
4452
|
exports.findElementsFromListByPositions = findElementsFromListByPositions;
|
|
4168
4453
|
exports.flatElementList = flatElementList;
|
|
4454
|
+
exports.flatObject = flatObject;
|
|
4169
4455
|
exports.formatNumber = formatNumber;
|
|
4170
4456
|
exports.generateHTML = generateHTML;
|
|
4171
4457
|
exports.generateSVGPath = generateSVGPath;
|
|
4458
|
+
exports.get = get;
|
|
4172
4459
|
exports.getCenterFromTwoPoints = getCenterFromTwoPoints;
|
|
4173
4460
|
exports.getDefaultElementDetailConfig = getDefaultElementDetailConfig;
|
|
4174
4461
|
exports.getDefaultElementRectDetail = getDefaultElementRectDetail;
|
|
@@ -4180,7 +4467,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4180
4467
|
exports.getElementVertexes = getElementVertexes;
|
|
4181
4468
|
exports.getGroupQueueByElementPosition = getGroupQueueByElementPosition;
|
|
4182
4469
|
exports.getGroupQueueFromList = getGroupQueueFromList;
|
|
4183
|
-
exports.getModifiedElement = getModifiedElement;
|
|
4184
4470
|
exports.getSelectedElementUUIDs = getSelectedElementUUIDs;
|
|
4185
4471
|
exports.getViewPointAtElement = getViewPointAtElement;
|
|
4186
4472
|
exports.getViewScaleInfoFromSnapshot = getViewScaleInfoFromSnapshot;
|
|
@@ -4204,9 +4490,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4204
4490
|
exports.matrixToAngle = matrixToAngle;
|
|
4205
4491
|
exports.matrixToRadian = matrixToRadian;
|
|
4206
4492
|
exports.merge = merge;
|
|
4493
|
+
exports.mergeElement = mergeElement;
|
|
4207
4494
|
exports.mergeElementAsset = mergeElementAsset;
|
|
4495
|
+
exports.mergeGlobal = mergeGlobal;
|
|
4208
4496
|
exports.mergeHexColorAlpha = mergeHexColorAlpha;
|
|
4209
|
-
exports.
|
|
4497
|
+
exports.mergeLayout = mergeLayout;
|
|
4210
4498
|
exports.moveElementPosition = moveElementPosition;
|
|
4211
4499
|
exports.omit = omit;
|
|
4212
4500
|
exports.originRectInfoToRangeRectInfo = originRectInfoToRangeRectInfo;
|
|
@@ -4223,10 +4511,16 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
4223
4511
|
exports.rotatePoint = rotatePoint;
|
|
4224
4512
|
exports.rotatePointInGroup = rotatePointInGroup;
|
|
4225
4513
|
exports.rotateVertexes = rotateVertexes;
|
|
4514
|
+
exports.set = set;
|
|
4226
4515
|
exports.sortDataAsserts = sortDataAsserts;
|
|
4227
4516
|
exports.throttle = throttle;
|
|
4228
4517
|
exports.toColorHexNum = toColorHexNum;
|
|
4229
4518
|
exports.toColorHexStr = toColorHexStr;
|
|
4519
|
+
exports.toFlattenElement = toFlattenElement;
|
|
4520
|
+
exports.toFlattenGlobal = toFlattenGlobal;
|
|
4521
|
+
exports.toFlattenLayout = toFlattenLayout;
|
|
4522
|
+
exports.toPath = toPath;
|
|
4523
|
+
exports.unflatObject = unflatObject;
|
|
4230
4524
|
exports.ungroupElementsByPosition = ungroupElementsByPosition;
|
|
4231
4525
|
exports.updateElementInList = updateElementInList;
|
|
4232
4526
|
exports.updateElementInListByPosition = updateElementInListByPosition;
|