@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.
Files changed (104) hide show
  1. package/dist/esm/index.d.ts +46 -40
  2. package/dist/esm/index.js +46 -40
  3. package/dist/esm/tool/flat-object.d.ts +6 -0
  4. package/dist/esm/tool/flat-object.js +28 -0
  5. package/dist/esm/tool/get-set-del.d.ts +4 -0
  6. package/dist/esm/tool/get-set-del.js +65 -0
  7. package/dist/esm/tool/hash.d.ts +1 -0
  8. package/dist/esm/tool/hash.js +33 -0
  9. package/dist/esm/{lib → tool}/html.js +6 -2
  10. package/dist/esm/{lib → tool}/store.js +1 -1
  11. package/dist/esm/tool/unflat-object.d.ts +3 -0
  12. package/dist/esm/tool/unflat-object.js +91 -0
  13. package/dist/esm/tool/uuid.js +13 -0
  14. package/dist/esm/{lib → view}/check.js +14 -14
  15. package/dist/esm/{lib → view}/controller.js +53 -10
  16. package/dist/esm/{lib → view}/data.js +1 -1
  17. package/dist/esm/{lib → view}/element.js +12 -4
  18. package/dist/esm/{lib → view}/flat.js +2 -1
  19. package/dist/esm/{lib → view}/group.js +1 -1
  20. package/dist/esm/{lib → view}/handle-element.d.ts +6 -1
  21. package/dist/esm/{lib → view}/handle-element.js +26 -31
  22. package/dist/esm/view/handle-global.d.ts +4 -0
  23. package/dist/esm/view/handle-global.js +28 -0
  24. package/dist/esm/view/handle-layout.d.ts +4 -0
  25. package/dist/esm/view/handle-layout.js +28 -0
  26. package/dist/esm/{lib → view}/is.js +1 -1
  27. package/dist/esm/view/modify-record.d.ts +4 -0
  28. package/dist/esm/view/modify-record.js +10 -0
  29. package/dist/esm/view/position.d.ts +15 -0
  30. package/dist/esm/view/position.js +79 -0
  31. package/dist/esm/{lib → view}/resize-element.js +1 -1
  32. package/dist/esm/{lib → view}/view-content.js +1 -1
  33. package/dist/index.global.js +459 -165
  34. package/dist/index.global.min.js +1 -1
  35. package/package.json +1 -1
  36. package/dist/esm/lib/modify-recorder.d.ts +0 -15
  37. package/dist/esm/lib/modify-recorder.js +0 -177
  38. package/dist/esm/lib/modify.d.ts +0 -6
  39. package/dist/esm/lib/modify.js +0 -99
  40. package/dist/esm/lib/uuid.js +0 -31
  41. /package/dist/esm/{lib → tool}/color.d.ts +0 -0
  42. /package/dist/esm/{lib → tool}/color.js +0 -0
  43. /package/dist/esm/{lib → tool}/event.d.ts +0 -0
  44. /package/dist/esm/{lib → tool}/event.js +0 -0
  45. /package/dist/esm/{lib → tool}/file.d.ts +0 -0
  46. /package/dist/esm/{lib → tool}/file.js +0 -0
  47. /package/dist/esm/{lib → tool}/html.d.ts +0 -0
  48. /package/dist/esm/{lib → tool}/image.d.ts +0 -0
  49. /package/dist/esm/{lib → tool}/image.js +0 -0
  50. /package/dist/esm/{lib → tool}/istype.d.ts +0 -0
  51. /package/dist/esm/{lib → tool}/istype.js +0 -0
  52. /package/dist/esm/{lib → tool}/merge.d.ts +0 -0
  53. /package/dist/esm/{lib → tool}/merge.js +0 -0
  54. /package/dist/esm/{lib → tool}/number.d.ts +0 -0
  55. /package/dist/esm/{lib → tool}/number.js +0 -0
  56. /package/dist/esm/{lib → tool}/omit.d.ts +0 -0
  57. /package/dist/esm/{lib → tool}/omit.js +0 -0
  58. /package/dist/esm/{lib → tool}/store.d.ts +0 -0
  59. /package/dist/esm/{lib → tool}/time.d.ts +0 -0
  60. /package/dist/esm/{lib → tool}/time.js +0 -0
  61. /package/dist/esm/{lib → tool}/uuid.d.ts +0 -0
  62. /package/dist/esm/{lib → view}/box.d.ts +0 -0
  63. /package/dist/esm/{lib → view}/box.js +0 -0
  64. /package/dist/esm/{lib → view}/canvas.d.ts +0 -0
  65. /package/dist/esm/{lib → view}/canvas.js +0 -0
  66. /package/dist/esm/{lib → view}/check.d.ts +0 -0
  67. /package/dist/esm/{lib → view}/config.d.ts +0 -0
  68. /package/dist/esm/{lib → view}/config.js +0 -0
  69. /package/dist/esm/{lib → view}/context2d.d.ts +0 -0
  70. /package/dist/esm/{lib → view}/context2d.js +0 -0
  71. /package/dist/esm/{lib → view}/controller.d.ts +0 -0
  72. /package/dist/esm/{lib → view}/data.d.ts +0 -0
  73. /package/dist/esm/{lib → view}/element.d.ts +0 -0
  74. /package/dist/esm/{lib → view}/flat.d.ts +0 -0
  75. /package/dist/esm/{lib → view}/group.d.ts +0 -0
  76. /package/dist/esm/{lib → view}/is.d.ts +0 -0
  77. /package/dist/esm/{lib → view}/load.d.ts +0 -0
  78. /package/dist/esm/{lib → view}/load.js +0 -0
  79. /package/dist/esm/{lib → view}/matrix.d.ts +0 -0
  80. /package/dist/esm/{lib → view}/matrix.js +0 -0
  81. /package/dist/esm/{lib → view}/middleware.d.ts +0 -0
  82. /package/dist/esm/{lib → view}/middleware.js +0 -0
  83. /package/dist/esm/{lib → view}/parser.d.ts +0 -0
  84. /package/dist/esm/{lib → view}/parser.js +0 -0
  85. /package/dist/esm/{lib → view}/point-move-element.d.ts +0 -0
  86. /package/dist/esm/{lib → view}/point-move-element.js +0 -0
  87. /package/dist/esm/{lib → view}/point.d.ts +0 -0
  88. /package/dist/esm/{lib → view}/point.js +0 -0
  89. /package/dist/esm/{lib → view}/rect.d.ts +0 -0
  90. /package/dist/esm/{lib → view}/rect.js +0 -0
  91. /package/dist/esm/{lib → view}/resize-element.d.ts +0 -0
  92. /package/dist/esm/{lib → view}/rotate.d.ts +0 -0
  93. /package/dist/esm/{lib → view}/rotate.js +0 -0
  94. /package/dist/esm/{lib → view}/svg-path.d.ts +0 -0
  95. /package/dist/esm/{lib → view}/svg-path.js +0 -0
  96. /package/dist/esm/{lib → view}/text.d.ts +0 -0
  97. /package/dist/esm/{lib → view}/text.js +0 -0
  98. /package/dist/esm/{lib → view}/vertex.d.ts +0 -0
  99. /package/dist/esm/{lib → view}/vertex.js +0 -0
  100. /package/dist/esm/{lib → view}/view-box.d.ts +0 -0
  101. /package/dist/esm/{lib → view}/view-box.js +0 -0
  102. /package/dist/esm/{lib → view}/view-calc.d.ts +0 -0
  103. /package/dist/esm/{lib → view}/view-calc.js +0 -0
  104. /package/dist/esm/{lib → view}/view-content.d.ts +0 -0
@@ -1,40 +1,46 @@
1
- export { delay, compose, throttle, debounce } from './lib/time';
2
- export { downloadImageFromCanvas, parseFileToBase64, pickFile, parseFileToText, downloadFileFromText } from './lib/file';
3
- export { toColorHexStr, toColorHexNum, isColorStr, colorNameToHex, colorToCSS, colorToLinearGradientCSS, mergeHexColorAlpha } from './lib/color';
4
- export { createUUID, isAssetId, createAssetId } from './lib/uuid';
5
- export { deepClone, sortDataAsserts, deepCloneElement, deepCloneData, filterCompactData } from './lib/data';
6
- export { istype } from './lib/istype';
7
- export { loadImage, loadSVG, loadHTML } from './lib/load';
8
- export { is } from './lib/is';
9
- export { check } from './lib/check';
10
- export { createBoardContent, createContext2D, createOffscreenContext2D } from './lib/canvas';
11
- export { EventEmitter } from './lib/event';
12
- export { calcDistance, calcSpeed, equalPoint, equalTouchPoint, vaildPoint, vaildTouchPoint, getCenterFromTwoPoints } from './lib/point';
13
- export { Store } from './lib/store';
14
- export { getViewScaleInfoFromSnapshot, getViewSizeInfoFromSnapshot } from './lib/middleware';
15
- export { Context2D } from './lib/context2d';
16
- export { rotateElement, parseRadianToAngle, parseAngleToRadian, rotateElementVertexes, getElementRotateVertexes, calcElementCenter, calcElementCenterFromVertexes, rotatePointInGroup, limitAngle, calcRadian } from './lib/rotate';
17
- export { getSelectedElementUUIDs, validateElements, calcElementsContextSize, calcElementsViewInfo, getElemenetsAssetIds, findElementFromList, findElementsFromList, findElementFromListByPosition, findElementQueueFromListByPosition, findElementsFromListByPositions, getGroupQueueFromList, getGroupQueueByElementPosition, getElementSize, mergeElementAsset, filterElementAsset, isResourceElement, getElementPositionFromList, getElementPositionMapFromList, calcElementListSize, isSameElementSize } from './lib/element';
18
- export { checkRectIntersect } from './lib/rect';
19
- export { viewScale, viewScroll, calcViewElementSize, calcViewPointSize, calcViewVertexes, isViewPointInElement, getViewPointAtElement, isElementInView, calcViewScaleInfo, calcElementViewRectInfo, calcElementOriginRectInfo, originRectInfoToRangeRectInfo, isViewPointInElementSize, isViewPointInVertexes } from './lib/view-calc';
20
- export { rotatePoint, rotateVertexes, rotateByCenter } from './lib/rotate';
21
- export { getElementVertexes, calcElementVertexesInGroup, calcElementVertexesQueueInGroup, calcElementQueueVertexesQueueInGroup } from './lib/vertex';
22
- export { calcElementSizeController, calcLayoutSizeController } from './lib/controller';
23
- export { generateSVGPath, parseSVGPath } from './lib/svg-path';
24
- export { generateHTML, parseHTML } from './lib/html';
25
- export { compressImage } from './lib/image';
26
- export { formatNumber } from './lib/number';
27
- export { matrixToAngle, matrixToRadian } from './lib/matrix';
28
- export { getDefaultElementDetailConfig, getDefaultElementRectDetail } from './lib/config';
29
- export { calcViewBoxSize } from './lib/view-box';
30
- export { createElement, insertElementToListByPosition, deleteElementInListByPosition, deleteElementInList, moveElementPosition, updateElementInList, updateElementInListByPosition } from './lib/handle-element';
31
- export { deepResizeGroupElement } from './lib/resize-element';
32
- export { calcViewCenterContent, calcViewCenter } from './lib/view-content';
33
- export { modifyElement, getModifiedElement } from './lib/modify';
34
- export { enhanceFontFamliy } from './lib/text';
35
- export { flatElementList } from './lib/flat';
36
- export { groupElementsByPosition, ungroupElementsByPosition } from './lib/group';
37
- export { calcPointMoveElementInGroup } from './lib/point-move-element';
38
- export { merge } from './lib/merge';
39
- export { omit } from './lib/omit';
40
- export { elementToBoxInfo } from './lib/box';
1
+ export { delay, compose, throttle, debounce } from './tool/time';
2
+ export { downloadImageFromCanvas, parseFileToBase64, pickFile, parseFileToText, downloadFileFromText } from './tool/file';
3
+ export { toColorHexStr, toColorHexNum, isColorStr, colorNameToHex, colorToCSS, colorToLinearGradientCSS, mergeHexColorAlpha } from './tool/color';
4
+ export { createUUID, isAssetId, createAssetId } from './tool/uuid';
5
+ export { deepClone, sortDataAsserts, deepCloneElement, deepCloneData, filterCompactData } from './view/data';
6
+ export { istype } from './tool/istype';
7
+ export { loadImage, loadSVG, loadHTML } from './view/load';
8
+ export { is } from './view/is';
9
+ export { check } from './view/check';
10
+ export { createBoardContent, createContext2D, createOffscreenContext2D } from './view/canvas';
11
+ export { EventEmitter } from './tool/event';
12
+ export { calcDistance, calcSpeed, equalPoint, equalTouchPoint, vaildPoint, vaildTouchPoint, getCenterFromTwoPoints } from './view/point';
13
+ export { Store } from './tool/store';
14
+ export { getViewScaleInfoFromSnapshot, getViewSizeInfoFromSnapshot } from './view/middleware';
15
+ export { Context2D } from './view/context2d';
16
+ export { rotateElement, parseRadianToAngle, parseAngleToRadian, rotateElementVertexes, getElementRotateVertexes, calcElementCenter, calcElementCenterFromVertexes, rotatePointInGroup, limitAngle, calcRadian } from './view/rotate';
17
+ export { getSelectedElementUUIDs, validateElements, calcElementsContextSize, calcElementsViewInfo, getElemenetsAssetIds, findElementFromList, findElementsFromList, findElementFromListByPosition, findElementQueueFromListByPosition, findElementsFromListByPositions, getGroupQueueFromList, getGroupQueueByElementPosition, getElementSize, mergeElementAsset, filterElementAsset, isResourceElement, getElementPositionFromList, getElementPositionMapFromList, calcElementListSize, isSameElementSize } from './view/element';
18
+ export { checkRectIntersect } from './view/rect';
19
+ export { viewScale, viewScroll, calcViewElementSize, calcViewPointSize, calcViewVertexes, isViewPointInElement, getViewPointAtElement, isElementInView, calcViewScaleInfo, calcElementViewRectInfo, calcElementOriginRectInfo, originRectInfoToRangeRectInfo, isViewPointInElementSize, isViewPointInVertexes } from './view/view-calc';
20
+ export { rotatePoint, rotateVertexes, rotateByCenter } from './view/rotate';
21
+ export { getElementVertexes, calcElementVertexesInGroup, calcElementVertexesQueueInGroup, calcElementQueueVertexesQueueInGroup } from './view/vertex';
22
+ export { calcElementSizeController, calcLayoutSizeController } from './view/controller';
23
+ export { generateSVGPath, parseSVGPath } from './view/svg-path';
24
+ export { generateHTML, parseHTML } from './tool/html';
25
+ export { compressImage } from './tool/image';
26
+ export { formatNumber } from './tool/number';
27
+ export { matrixToAngle, matrixToRadian } from './view/matrix';
28
+ export { getDefaultElementDetailConfig, getDefaultElementRectDetail } from './view/config';
29
+ export { calcViewBoxSize } from './view/view-box';
30
+ export { mergeElement, createElement, insertElementToListByPosition, deleteElementInListByPosition, deleteElementInList, moveElementPosition, updateElementInList, updateElementInListByPosition } from './view/handle-element';
31
+ export { deepResizeGroupElement } from './view/resize-element';
32
+ export { calcViewCenterContent, calcViewCenter } from './view/view-content';
33
+ export { toFlattenElement, toFlattenLayout, toFlattenGlobal } from './view/modify-record';
34
+ export { enhanceFontFamliy } from './view/text';
35
+ export { flatElementList } from './view/flat';
36
+ export { groupElementsByPosition, ungroupElementsByPosition } from './view/group';
37
+ export { calcPointMoveElementInGroup } from './view/point-move-element';
38
+ export { mergeLayout } from './view/handle-layout';
39
+ export { mergeGlobal } from './view/handle-global';
40
+ export { calcRevertMovePosition, calcResultMovePosition } from './view/position';
41
+ export { merge } from './tool/merge';
42
+ export { omit } from './tool/omit';
43
+ export { elementToBoxInfo } from './view/box';
44
+ export { get, set, toPath } from './tool/get-set-del';
45
+ export { flatObject } from './tool/flat-object';
46
+ export { unflatObject } from './tool/unflat-object';
package/dist/esm/index.js CHANGED
@@ -1,40 +1,46 @@
1
- export { delay, compose, throttle, debounce } from './lib/time';
2
- export { downloadImageFromCanvas, parseFileToBase64, pickFile, parseFileToText, downloadFileFromText } from './lib/file';
3
- export { toColorHexStr, toColorHexNum, isColorStr, colorNameToHex, colorToCSS, colorToLinearGradientCSS, mergeHexColorAlpha } from './lib/color';
4
- export { createUUID, isAssetId, createAssetId } from './lib/uuid';
5
- export { deepClone, sortDataAsserts, deepCloneElement, deepCloneData, filterCompactData } from './lib/data';
6
- export { istype } from './lib/istype';
7
- export { loadImage, loadSVG, loadHTML } from './lib/load';
8
- export { is } from './lib/is';
9
- export { check } from './lib/check';
10
- export { createBoardContent, createContext2D, createOffscreenContext2D } from './lib/canvas';
11
- export { EventEmitter } from './lib/event';
12
- export { calcDistance, calcSpeed, equalPoint, equalTouchPoint, vaildPoint, vaildTouchPoint, getCenterFromTwoPoints } from './lib/point';
13
- export { Store } from './lib/store';
14
- export { getViewScaleInfoFromSnapshot, getViewSizeInfoFromSnapshot } from './lib/middleware';
15
- export { Context2D } from './lib/context2d';
16
- export { rotateElement, parseRadianToAngle, parseAngleToRadian, rotateElementVertexes, getElementRotateVertexes, calcElementCenter, calcElementCenterFromVertexes, rotatePointInGroup, limitAngle, calcRadian } from './lib/rotate';
17
- export { getSelectedElementUUIDs, validateElements, calcElementsContextSize, calcElementsViewInfo, getElemenetsAssetIds, findElementFromList, findElementsFromList, findElementFromListByPosition, findElementQueueFromListByPosition, findElementsFromListByPositions, getGroupQueueFromList, getGroupQueueByElementPosition, getElementSize, mergeElementAsset, filterElementAsset, isResourceElement, getElementPositionFromList, getElementPositionMapFromList, calcElementListSize, isSameElementSize } from './lib/element';
18
- export { checkRectIntersect } from './lib/rect';
19
- export { viewScale, viewScroll, calcViewElementSize, calcViewPointSize, calcViewVertexes, isViewPointInElement, getViewPointAtElement, isElementInView, calcViewScaleInfo, calcElementViewRectInfo, calcElementOriginRectInfo, originRectInfoToRangeRectInfo, isViewPointInElementSize, isViewPointInVertexes } from './lib/view-calc';
20
- export { rotatePoint, rotateVertexes, rotateByCenter } from './lib/rotate';
21
- export { getElementVertexes, calcElementVertexesInGroup, calcElementVertexesQueueInGroup, calcElementQueueVertexesQueueInGroup } from './lib/vertex';
22
- export { calcElementSizeController, calcLayoutSizeController } from './lib/controller';
23
- export { generateSVGPath, parseSVGPath } from './lib/svg-path';
24
- export { generateHTML, parseHTML } from './lib/html';
25
- export { compressImage } from './lib/image';
26
- export { formatNumber } from './lib/number';
27
- export { matrixToAngle, matrixToRadian } from './lib/matrix';
28
- export { getDefaultElementDetailConfig, getDefaultElementRectDetail } from './lib/config';
29
- export { calcViewBoxSize } from './lib/view-box';
30
- export { createElement, insertElementToListByPosition, deleteElementInListByPosition, deleteElementInList, moveElementPosition, updateElementInList, updateElementInListByPosition } from './lib/handle-element';
31
- export { deepResizeGroupElement } from './lib/resize-element';
32
- export { calcViewCenterContent, calcViewCenter } from './lib/view-content';
33
- export { modifyElement, getModifiedElement } from './lib/modify';
34
- export { enhanceFontFamliy } from './lib/text';
35
- export { flatElementList } from './lib/flat';
36
- export { groupElementsByPosition, ungroupElementsByPosition } from './lib/group';
37
- export { calcPointMoveElementInGroup } from './lib/point-move-element';
38
- export { merge } from './lib/merge';
39
- export { omit } from './lib/omit';
40
- export { elementToBoxInfo } from './lib/box';
1
+ export { delay, compose, throttle, debounce } from './tool/time';
2
+ export { downloadImageFromCanvas, parseFileToBase64, pickFile, parseFileToText, downloadFileFromText } from './tool/file';
3
+ export { toColorHexStr, toColorHexNum, isColorStr, colorNameToHex, colorToCSS, colorToLinearGradientCSS, mergeHexColorAlpha } from './tool/color';
4
+ export { createUUID, isAssetId, createAssetId } from './tool/uuid';
5
+ export { deepClone, sortDataAsserts, deepCloneElement, deepCloneData, filterCompactData } from './view/data';
6
+ export { istype } from './tool/istype';
7
+ export { loadImage, loadSVG, loadHTML } from './view/load';
8
+ export { is } from './view/is';
9
+ export { check } from './view/check';
10
+ export { createBoardContent, createContext2D, createOffscreenContext2D } from './view/canvas';
11
+ export { EventEmitter } from './tool/event';
12
+ export { calcDistance, calcSpeed, equalPoint, equalTouchPoint, vaildPoint, vaildTouchPoint, getCenterFromTwoPoints } from './view/point';
13
+ export { Store } from './tool/store';
14
+ export { getViewScaleInfoFromSnapshot, getViewSizeInfoFromSnapshot } from './view/middleware';
15
+ export { Context2D } from './view/context2d';
16
+ export { rotateElement, parseRadianToAngle, parseAngleToRadian, rotateElementVertexes, getElementRotateVertexes, calcElementCenter, calcElementCenterFromVertexes, rotatePointInGroup, limitAngle, calcRadian } from './view/rotate';
17
+ export { getSelectedElementUUIDs, validateElements, calcElementsContextSize, calcElementsViewInfo, getElemenetsAssetIds, findElementFromList, findElementsFromList, findElementFromListByPosition, findElementQueueFromListByPosition, findElementsFromListByPositions, getGroupQueueFromList, getGroupQueueByElementPosition, getElementSize, mergeElementAsset, filterElementAsset, isResourceElement, getElementPositionFromList, getElementPositionMapFromList, calcElementListSize, isSameElementSize } from './view/element';
18
+ export { checkRectIntersect } from './view/rect';
19
+ export { viewScale, viewScroll, calcViewElementSize, calcViewPointSize, calcViewVertexes, isViewPointInElement, getViewPointAtElement, isElementInView, calcViewScaleInfo, calcElementViewRectInfo, calcElementOriginRectInfo, originRectInfoToRangeRectInfo, isViewPointInElementSize, isViewPointInVertexes } from './view/view-calc';
20
+ export { rotatePoint, rotateVertexes, rotateByCenter } from './view/rotate';
21
+ export { getElementVertexes, calcElementVertexesInGroup, calcElementVertexesQueueInGroup, calcElementQueueVertexesQueueInGroup } from './view/vertex';
22
+ export { calcElementSizeController, calcLayoutSizeController } from './view/controller';
23
+ export { generateSVGPath, parseSVGPath } from './view/svg-path';
24
+ export { generateHTML, parseHTML } from './tool/html';
25
+ export { compressImage } from './tool/image';
26
+ export { formatNumber } from './tool/number';
27
+ export { matrixToAngle, matrixToRadian } from './view/matrix';
28
+ export { getDefaultElementDetailConfig, getDefaultElementRectDetail } from './view/config';
29
+ export { calcViewBoxSize } from './view/view-box';
30
+ export { mergeElement, createElement, insertElementToListByPosition, deleteElementInListByPosition, deleteElementInList, moveElementPosition, updateElementInList, updateElementInListByPosition } from './view/handle-element';
31
+ export { deepResizeGroupElement } from './view/resize-element';
32
+ export { calcViewCenterContent, calcViewCenter } from './view/view-content';
33
+ export { toFlattenElement, toFlattenLayout, toFlattenGlobal } from './view/modify-record';
34
+ export { enhanceFontFamliy } from './view/text';
35
+ export { flatElementList } from './view/flat';
36
+ export { groupElementsByPosition, ungroupElementsByPosition } from './view/group';
37
+ export { calcPointMoveElementInGroup } from './view/point-move-element';
38
+ export { mergeLayout } from './view/handle-layout';
39
+ export { mergeGlobal } from './view/handle-global';
40
+ export { calcRevertMovePosition, calcResultMovePosition } from './view/position';
41
+ export { merge } from './tool/merge';
42
+ export { omit } from './tool/omit';
43
+ export { elementToBoxInfo } from './view/box';
44
+ export { get, set, toPath } from './tool/get-set-del';
45
+ export { flatObject } from './tool/flat-object';
46
+ export { unflatObject } from './tool/unflat-object';
@@ -0,0 +1,6 @@
1
+ type FlattenedObject = Record<string, any>;
2
+ type FlatObjectOptions = {
3
+ ignorePaths?: string[];
4
+ };
5
+ export declare function flatObject<T extends Record<string, any>>(obj: T, opts?: FlatObjectOptions): FlattenedObject;
6
+ export {};
@@ -0,0 +1,28 @@
1
+ function flattenObject(obj, parentKey = '', result = {}, opts) {
2
+ Object.keys(obj).forEach((key) => {
3
+ var _a;
4
+ const currentKey = parentKey ? `${parentKey}${isArrayIndex(key) ? `[${key}]` : `.${key}`}` : key;
5
+ if (!((_a = opts === null || opts === void 0 ? void 0 : opts.ignorePaths) === null || _a === void 0 ? void 0 : _a.includes(currentKey))) {
6
+ const value = obj[key];
7
+ if (isFlattenable(value)) {
8
+ flattenObject(value, Array.isArray(value) ? currentKey : currentKey, result, opts);
9
+ }
10
+ else {
11
+ result[currentKey] = value;
12
+ }
13
+ }
14
+ });
15
+ return result;
16
+ }
17
+ function isFlattenable(value) {
18
+ return (typeof value === 'object' && value !== null && !(value instanceof Date)) || Array.isArray(value);
19
+ }
20
+ function isArrayIndex(key) {
21
+ return /^\d+$/.test(key) && !isNaN(Number(key));
22
+ }
23
+ export function flatObject(obj, opts) {
24
+ if (typeof obj !== 'object' || obj === null) {
25
+ return { '': obj };
26
+ }
27
+ return flattenObject(obj, '', {}, opts);
28
+ }
@@ -0,0 +1,4 @@
1
+ export declare function toPath(path: string | string[]): string[];
2
+ export declare function get<T = any, D = any>(obj: T, path: string | string[], defaultValue?: D): D | undefined;
3
+ export declare function set<T = any>(obj: T, path: string | string[], value: any): T;
4
+ export declare function del<T = any>(obj: T, path: string | string[]): T;
@@ -0,0 +1,65 @@
1
+ export function toPath(path) {
2
+ if (Array.isArray(path))
3
+ return [...path];
4
+ return path.split(/\.|\[|\]/).filter((key) => key !== '');
5
+ }
6
+ export function get(obj, path, defaultValue) {
7
+ if (!path) {
8
+ return undefined;
9
+ }
10
+ const pathArray = toPath(path);
11
+ let current = obj;
12
+ for (const key of pathArray) {
13
+ if (current === null || current === undefined) {
14
+ return defaultValue;
15
+ }
16
+ current = current[key];
17
+ }
18
+ return current !== undefined ? current : defaultValue;
19
+ }
20
+ export function set(obj, path, value) {
21
+ const pathArray = toPath(path);
22
+ if (pathArray.length === 0) {
23
+ return obj;
24
+ }
25
+ let current = obj;
26
+ if (current) {
27
+ for (let i = 0; i < pathArray.length; i++) {
28
+ const key = pathArray[i];
29
+ if (i === pathArray.length - 1) {
30
+ current[key] = value;
31
+ break;
32
+ }
33
+ if (current && ((current === null || current === void 0 ? void 0 : current[key]) === undefined || typeof (current === null || current === void 0 ? void 0 : current[key]) !== 'object' || (current === null || current === void 0 ? void 0 : current[key]) === null)) {
34
+ const nextKey = pathArray[i + 1];
35
+ const isNextNumeric = /^\d+$/.test(nextKey);
36
+ current[key] = isNextNumeric ? [] : {};
37
+ }
38
+ current = current === null || current === void 0 ? void 0 : current[key];
39
+ }
40
+ }
41
+ return obj;
42
+ }
43
+ export function del(obj, path) {
44
+ const pathArray = toPath(path);
45
+ if (pathArray.length === 0) {
46
+ return obj;
47
+ }
48
+ let current = obj;
49
+ if (current) {
50
+ for (let i = 0; i < pathArray.length; i++) {
51
+ const key = pathArray[i];
52
+ if (i === pathArray.length - 1) {
53
+ delete current[key];
54
+ break;
55
+ }
56
+ if (current && ((current === null || current === void 0 ? void 0 : current[key]) === undefined || typeof (current === null || current === void 0 ? void 0 : current[key]) !== 'object' || (current === null || current === void 0 ? void 0 : current[key]) === null)) {
57
+ const nextKey = pathArray[i + 1];
58
+ const isNextNumeric = /^\d+$/.test(nextKey);
59
+ current[key] = isNextNumeric ? [] : {};
60
+ }
61
+ current = current === null || current === void 0 ? void 0 : current[key];
62
+ }
63
+ }
64
+ return obj;
65
+ }
@@ -0,0 +1 @@
1
+ export declare function generate32Base36Hash(str: string): string;
@@ -0,0 +1,33 @@
1
+ export function generate32Base36Hash(str) {
2
+ const hash256 = generate256BitHash(str);
3
+ return bigIntToBase36(hash256).padStart(32, '0').slice(0, 32);
4
+ }
5
+ function generate256BitHash(str) {
6
+ let h1 = 0xcbf29ce484222325n, h2 = 0x84222325cbf29ce4n;
7
+ let h3 = 0x1b3n * h1, h4 = 0x1000000n * h2;
8
+ const prime = 0x100000001b3n;
9
+ const chunkSize = 4096;
10
+ for (let i = 0; i < str.length; i += chunkSize) {
11
+ const chunk = str.slice(i, i + chunkSize);
12
+ for (let j = 0; j < chunk.length; j++) {
13
+ const code = BigInt(chunk.charCodeAt(j) + i + j);
14
+ h1 = (h1 ^ code) * prime;
15
+ h2 = ((h2 ^ h1) * prime) ^ h3;
16
+ h3 = (h3 ^ h2) * prime + h4;
17
+ h4 = ((h4 ^ h3) * prime) | 0x1234567890abcdefn;
18
+ }
19
+ }
20
+ return (h1 << 192n) | (h2 << 128n) | (h3 << 64n) | h4;
21
+ }
22
+ function bigIntToBase36(num) {
23
+ const chars = '0123456789abcdefghijklmnopqrstuvwxyz';
24
+ if (num === 0n)
25
+ return '0';
26
+ let result = '';
27
+ while (num > 0n) {
28
+ const rem = num % 36n;
29
+ result = chars[Number(rem)] + result;
30
+ num = num / 36n;
31
+ }
32
+ return result;
33
+ }
@@ -140,7 +140,7 @@ export function parseHTML(html) {
140
140
  }
141
141
  function attrString(attrs) {
142
142
  const buff = [];
143
- for (let key in attrs) {
143
+ for (const key in attrs) {
144
144
  buff.push(key + '="' + attrs[key] + '"');
145
145
  }
146
146
  if (!buff.length) {
@@ -153,7 +153,11 @@ function stringify(buff, htmlNode) {
153
153
  case 'text':
154
154
  return buff + htmlNode.textContent;
155
155
  case 'element':
156
- buff += '<' + htmlNode.name + (htmlNode.attributes ? attrString(htmlNode.attributes) : '') + (htmlNode.isVoid ? '/>' : '>');
156
+ buff +=
157
+ '<' +
158
+ htmlNode.name +
159
+ (htmlNode.attributes ? attrString(htmlNode.attributes) : '') +
160
+ (htmlNode.isVoid ? '/>' : '>');
157
161
  if (htmlNode.isVoid) {
158
162
  return buff;
159
163
  }
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _Store_instances, _Store_temp, _Store_backUpDefaultStorage, _Store_static, _Store_createTempStorage;
13
- import { deepClone } from './data';
13
+ import { deepClone } from '../view/data';
14
14
  export class Store {
15
15
  constructor(opts) {
16
16
  _Store_instances.add(this);
@@ -0,0 +1,3 @@
1
+ type NestedStructure = object | unknown[];
2
+ export declare function unflatObject<T extends Record<string, unknown>>(flatObj: T): NestedStructure;
3
+ export {};
@@ -0,0 +1,91 @@
1
+ export function unflatObject(flatObj) {
2
+ const result = {};
3
+ for (const [flatKey, value] of Object.entries(flatObj)) {
4
+ const pathParts = parseKeyToPath(flatKey);
5
+ buildNestedStructure(result, pathParts, value);
6
+ }
7
+ return result;
8
+ }
9
+ function parseKeyToPath(flatKey) {
10
+ const regex = /([\w-]+)|\[(\d+)\]/g;
11
+ const pathParts = [];
12
+ let match;
13
+ while ((match = regex.exec(flatKey)) !== null) {
14
+ const prop = match[1] || match[2];
15
+ if (prop) {
16
+ pathParts.push(prop);
17
+ }
18
+ }
19
+ return pathParts;
20
+ }
21
+ function buildNestedStructure(currentObj, pathParts, value) {
22
+ let currentLevel = currentObj;
23
+ for (let i = 0; i < pathParts.length; i++) {
24
+ const part = pathParts[i];
25
+ const isArrayPart = isArrayIndex(part);
26
+ const isLast = i === pathParts.length - 1;
27
+ try {
28
+ if (isArrayPart) {
29
+ validateArrayPath(currentLevel, part);
30
+ }
31
+ else {
32
+ validateObjectPath(currentLevel, part);
33
+ }
34
+ }
35
+ catch (e) {
36
+ throw new Error(`Structure conflict at path '${pathParts.slice(0, i + 1).join('.')}': ${e.message}`);
37
+ }
38
+ if (isLast) {
39
+ assignValue(currentLevel, part, value);
40
+ }
41
+ else {
42
+ currentLevel = prepareNextLevel(currentLevel, part, pathParts[i + 1]);
43
+ }
44
+ }
45
+ }
46
+ function isArrayIndex(key) {
47
+ return /^\d+$/.test(key);
48
+ }
49
+ function validateArrayPath(obj, index) {
50
+ if (!Array.isArray(obj)) {
51
+ throw new Error(`Expected array but found ${typeof obj}`);
52
+ }
53
+ const idx = Number(index);
54
+ if (idx > obj.length) {
55
+ obj.length = idx + 1;
56
+ }
57
+ }
58
+ function validateObjectPath(obj, key) {
59
+ if (Array.isArray(obj)) {
60
+ throw new Error(`Cannot create object property '${key}' on array`);
61
+ }
62
+ if (typeof obj !== 'object' || obj === null) {
63
+ throw new Error(`Invalid structure for property '${key}'`);
64
+ }
65
+ }
66
+ function prepareNextLevel(current, part, nextPart) {
67
+ const isNextArray = nextPart ? isArrayIndex(nextPart) : false;
68
+ if (Array.isArray(current)) {
69
+ const index = Number(part);
70
+ if (!current[index]) {
71
+ current[index] = isNextArray ? [] : {};
72
+ }
73
+ return current[index];
74
+ }
75
+ if (!current[part]) {
76
+ current[part] = isNextArray ? [] : {};
77
+ }
78
+ return current[part];
79
+ }
80
+ function assignValue(target, key, value) {
81
+ if (Array.isArray(target)) {
82
+ const index = Number(key);
83
+ if (index >= target.length) {
84
+ target.length = index + 1;
85
+ }
86
+ target[index] = value;
87
+ }
88
+ else {
89
+ target[key] = value;
90
+ }
91
+ }
@@ -0,0 +1,13 @@
1
+ import { generate32Base36Hash } from './hash';
2
+ export function createUUID() {
3
+ function _createStr() {
4
+ return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
5
+ }
6
+ return `${_createStr()}${_createStr()}-${_createStr()}-${_createStr()}-${_createStr()}-${_createStr()}${_createStr()}${_createStr()}`;
7
+ }
8
+ export function createAssetId(assetStr) {
9
+ return `@assets/${generate32Base36Hash(assetStr)}`;
10
+ }
11
+ export function isAssetId(id) {
12
+ return /^@assets\/[0-9a-z-]{0,}$/.test(`${id}`);
13
+ }
@@ -11,20 +11,20 @@ function attrs(attrs) {
11
11
  }
12
12
  function box(detail = {}) {
13
13
  const { borderColor, borderRadius, borderWidth } = detail;
14
- if (detail.hasOwnProperty('borderColor') && !is.color(borderColor)) {
14
+ if (Object.prototype.hasOwnProperty.call(detail, 'borderColor') && !is.color(borderColor)) {
15
15
  return false;
16
16
  }
17
- if (detail.hasOwnProperty('borderRadius') && !is.number(borderRadius)) {
17
+ if (Object.prototype.hasOwnProperty.call(detail, 'borderRadius') && !is.number(borderRadius)) {
18
18
  return false;
19
19
  }
20
- if (detail.hasOwnProperty('borderWidth') && !is.number(borderWidth)) {
20
+ if (Object.prototype.hasOwnProperty.call(detail, 'borderWidth') && !is.number(borderWidth)) {
21
21
  return false;
22
22
  }
23
23
  return true;
24
24
  }
25
25
  function rectDesc(detail) {
26
26
  const { background } = detail;
27
- if (detail.hasOwnProperty('background') && !is.color(background)) {
27
+ if (Object.prototype.hasOwnProperty.call(detail, 'background') && !is.color(background)) {
28
28
  return false;
29
29
  }
30
30
  if (!box(detail)) {
@@ -34,13 +34,13 @@ function rectDesc(detail) {
34
34
  }
35
35
  function circleDesc(detail) {
36
36
  const { background, borderColor, borderWidth } = detail;
37
- if (detail.hasOwnProperty('background') && !is.color(background)) {
37
+ if (Object.prototype.hasOwnProperty.call(detail, 'background') && !is.color(background)) {
38
38
  return false;
39
39
  }
40
- if (detail.hasOwnProperty('borderColor') && !is.color(borderColor)) {
40
+ if (Object.prototype.hasOwnProperty.call(detail, 'borderColor') && !is.color(borderColor)) {
41
41
  return false;
42
42
  }
43
- if (detail.hasOwnProperty('borderWidth') && !is.number(borderWidth)) {
43
+ if (Object.prototype.hasOwnProperty.call(detail, 'borderWidth') && !is.number(borderWidth)) {
44
44
  return false;
45
45
  }
46
46
  return true;
@@ -77,25 +77,25 @@ function textDesc(detail) {
77
77
  if (!is.fontSize(fontSize)) {
78
78
  return false;
79
79
  }
80
- if (detail.hasOwnProperty('background') && !is.color(background)) {
80
+ if (Object.prototype.hasOwnProperty.call(detail, 'background') && !is.color(background)) {
81
81
  return false;
82
82
  }
83
- if (detail.hasOwnProperty('fontWeight') && !is.fontWeight(fontWeight)) {
83
+ if (Object.prototype.hasOwnProperty.call(detail, 'fontWeight') && !is.fontWeight(fontWeight)) {
84
84
  return false;
85
85
  }
86
- if (detail.hasOwnProperty('lineHeight') && !is.lineHeight(lineHeight)) {
86
+ if (Object.prototype.hasOwnProperty.call(detail, 'lineHeight') && !is.lineHeight(lineHeight)) {
87
87
  return false;
88
88
  }
89
- if (detail.hasOwnProperty('fontFamily') && !is.fontFamily(fontFamily)) {
89
+ if (Object.prototype.hasOwnProperty.call(detail, 'fontFamily') && !is.fontFamily(fontFamily)) {
90
90
  return false;
91
91
  }
92
- if (detail.hasOwnProperty('textAlign') && !is.textAlign(textAlign)) {
92
+ if (Object.prototype.hasOwnProperty.call(detail, 'textAlign') && !is.textAlign(textAlign)) {
93
93
  return false;
94
94
  }
95
- if (detail.hasOwnProperty('strokeWidth') && !is.strokeWidth(strokeWidth)) {
95
+ if (Object.prototype.hasOwnProperty.call(detail, 'strokeWidth') && !is.strokeWidth(strokeWidth)) {
96
96
  return false;
97
97
  }
98
- if (detail.hasOwnProperty('strokeColor') && !is.color(strokeColor)) {
98
+ if (Object.prototype.hasOwnProperty.call(detail, 'strokeColor') && !is.color(strokeColor)) {
99
99
  return false;
100
100
  }
101
101
  if (!box(detail)) {
@@ -1,4 +1,4 @@
1
- import { createUUID } from './uuid';
1
+ import { createUUID } from '../tool/uuid';
2
2
  import { getCenterFromTwoPoints } from './point';
3
3
  import { calcElementVertexesInGroup, calcElementVertexes } from './vertex';
4
4
  import { calcViewElementSize } from './view-calc';
@@ -62,15 +62,38 @@ export function calcElementSizeController(elemSize, opts) {
62
62
  const topLeftSize = createControllerElementSizeFromCenter(topLeftCenter, { size: ctrlSize, angle: totalAngle });
63
63
  const topRightSize = createControllerElementSizeFromCenter(topRightCenter, { size: ctrlSize, angle: totalAngle });
64
64
  const bottomLeftSize = createControllerElementSizeFromCenter(bottomLeftCenter, { size: ctrlSize, angle: totalAngle });
65
- const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, { size: ctrlSize, angle: totalAngle });
65
+ const bottomRightSize = createControllerElementSizeFromCenter(bottomRightCenter, {
66
+ size: ctrlSize,
67
+ angle: totalAngle
68
+ });
66
69
  const topLeftVertexes = calcElementVertexes(topLeftSize);
67
70
  const topRightVertexes = calcElementVertexes(topRightSize);
68
71
  const bottomLeftVertexes = calcElementVertexes(bottomLeftSize);
69
72
  const bottomRightVertexes = calcElementVertexes(bottomRightSize);
70
- const topVertexes = [topLeftVertexes[1], topRightVertexes[0], topRightVertexes[3], topLeftVertexes[2]];
71
- const rightVertexes = [topRightVertexes[3], topRightVertexes[2], bottomRightVertexes[1], bottomRightVertexes[0]];
72
- const bottomVertexes = [bottomLeftVertexes[1], bottomRightVertexes[0], bottomRightVertexes[3], bottomLeftVertexes[2]];
73
- const leftVertexes = [topLeftVertexes[3], topLeftVertexes[2], bottomLeftVertexes[1], bottomLeftVertexes[0]];
73
+ const topVertexes = [
74
+ topLeftVertexes[1],
75
+ topRightVertexes[0],
76
+ topRightVertexes[3],
77
+ topLeftVertexes[2]
78
+ ];
79
+ const rightVertexes = [
80
+ topRightVertexes[3],
81
+ topRightVertexes[2],
82
+ bottomRightVertexes[1],
83
+ bottomRightVertexes[0]
84
+ ];
85
+ const bottomVertexes = [
86
+ bottomLeftVertexes[1],
87
+ bottomRightVertexes[0],
88
+ bottomRightVertexes[3],
89
+ bottomLeftVertexes[2]
90
+ ];
91
+ const leftVertexes = [
92
+ topLeftVertexes[3],
93
+ topLeftVertexes[2],
94
+ bottomLeftVertexes[1],
95
+ bottomLeftVertexes[0]
96
+ ];
74
97
  const topMiddleVertexes = calcElementVertexes(topMiddleSize);
75
98
  const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
76
99
  const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);
@@ -192,10 +215,30 @@ export function calcLayoutSizeController(layoutSize, opts) {
192
215
  const topRightVertexes = calcElementVertexes(topRightSize);
193
216
  const bottomLeftVertexes = calcElementVertexes(bottomLeftSize);
194
217
  const bottomRightVertexes = calcElementVertexes(bottomRightSize);
195
- const topVertexes = [topLeftVertexes[1], topRightVertexes[0], topRightVertexes[3], topLeftVertexes[2]];
196
- const rightVertexes = [topRightVertexes[3], topRightVertexes[2], bottomRightVertexes[1], bottomRightVertexes[0]];
197
- const bottomVertexes = [bottomLeftVertexes[1], bottomRightVertexes[0], bottomRightVertexes[3], bottomLeftVertexes[2]];
198
- const leftVertexes = [topLeftVertexes[3], topLeftVertexes[2], bottomLeftVertexes[1], bottomLeftVertexes[0]];
218
+ const topVertexes = [
219
+ topLeftVertexes[1],
220
+ topRightVertexes[0],
221
+ topRightVertexes[3],
222
+ topLeftVertexes[2]
223
+ ];
224
+ const rightVertexes = [
225
+ topRightVertexes[3],
226
+ topRightVertexes[2],
227
+ bottomRightVertexes[1],
228
+ bottomRightVertexes[0]
229
+ ];
230
+ const bottomVertexes = [
231
+ bottomLeftVertexes[1],
232
+ bottomRightVertexes[0],
233
+ bottomRightVertexes[3],
234
+ bottomLeftVertexes[2]
235
+ ];
236
+ const leftVertexes = [
237
+ topLeftVertexes[3],
238
+ topLeftVertexes[2],
239
+ bottomLeftVertexes[1],
240
+ bottomLeftVertexes[0]
241
+ ];
199
242
  const topMiddleVertexes = calcElementVertexes(topMiddleSize);
200
243
  const rightMiddleVertexes = calcElementVertexes(rightMiddleSize);
201
244
  const bottomMiddleVertexes = calcElementVertexes(bottomMiddleSize);