@idraw/util 0.4.2 → 1.0.0-alpha.1

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 (96) hide show
  1. package/dist/esm/converter/data-svg.d.ts +2 -0
  2. package/dist/esm/converter/data-svg.js +19 -0
  3. package/dist/esm/converter/material-svg.d.ts +2 -0
  4. package/dist/esm/converter/material-svg.js +63 -0
  5. package/dist/esm/converter/svg-material.d.ts +2 -0
  6. package/dist/esm/converter/svg-material.js +188 -0
  7. package/dist/esm/index.d.ts +32 -21
  8. package/dist/esm/index.js +32 -21
  9. package/dist/esm/static.d.ts +1 -0
  10. package/dist/esm/static.js +1 -0
  11. package/dist/esm/tool/file.js +2 -2
  12. package/dist/esm/tool/html.js +27 -27
  13. package/dist/esm/tool/id.d.ts +1 -0
  14. package/dist/esm/tool/id.js +4 -0
  15. package/dist/esm/tool/image.js +6 -6
  16. package/dist/esm/tool/path-to-box.d.ts +3 -0
  17. package/dist/esm/tool/path-to-box.js +353 -0
  18. package/dist/esm/tool/path-to-command.d.ts +4 -0
  19. package/dist/esm/tool/path-to-command.js +392 -0
  20. package/dist/esm/tool/path.d.ts +18 -0
  21. package/dist/esm/tool/path.js +421 -0
  22. package/dist/esm/tool/svg-path.d.ts +3 -0
  23. package/dist/esm/{view → tool}/svg-path.js +4 -16
  24. package/dist/esm/tool/time.d.ts +2 -2
  25. package/dist/esm/tool/time.js +4 -4
  26. package/dist/esm/tool/uuid.d.ts +1 -1
  27. package/dist/esm/tool/uuid.js +6 -6
  28. package/dist/esm/view/box.d.ts +0 -2
  29. package/dist/esm/view/box.js +1 -173
  30. package/dist/esm/view/canvas.js +3 -3
  31. package/dist/esm/view/check.d.ts +8 -7
  32. package/dist/esm/view/check.js +34 -34
  33. package/dist/esm/view/config.d.ts +0 -9
  34. package/dist/esm/view/config.js +1 -71
  35. package/dist/esm/view/context2d.d.ts +10 -3
  36. package/dist/esm/view/context2d.js +39 -18
  37. package/dist/esm/view/controller.d.ts +5 -5
  38. package/dist/esm/view/controller.js +105 -102
  39. package/dist/esm/view/data.d.ts +2 -2
  40. package/dist/esm/view/data.js +65 -65
  41. package/dist/esm/view/dom.d.ts +23 -0
  42. package/dist/esm/view/dom.js +190 -0
  43. package/dist/esm/view/flat.d.ts +2 -2
  44. package/dist/esm/view/flat.js +53 -53
  45. package/dist/esm/view/group.d.ts +3 -3
  46. package/dist/esm/view/group.js +25 -28
  47. package/dist/esm/view/handle-material.d.ts +24 -0
  48. package/dist/esm/view/{handle-element.js → handle-material.js} +98 -75
  49. package/dist/esm/view/is.d.ts +10 -12
  50. package/dist/esm/view/is.js +15 -19
  51. package/dist/esm/view/load.d.ts +2 -2
  52. package/dist/esm/view/load.js +7 -7
  53. package/dist/esm/view/material.d.ts +40 -0
  54. package/dist/esm/view/material.js +476 -0
  55. package/dist/esm/view/middleware.d.ts +1 -0
  56. package/dist/esm/view/middleware.js +14 -2
  57. package/dist/esm/view/modify-record.d.ts +4 -4
  58. package/dist/esm/view/modify-record.js +2 -2
  59. package/dist/esm/view/parser.d.ts +2 -2
  60. package/dist/esm/view/parser.js +3 -3
  61. package/dist/esm/view/path.d.ts +2 -0
  62. package/dist/esm/view/path.js +30 -0
  63. package/dist/esm/view/point-move-material.d.ts +5 -0
  64. package/dist/esm/view/{point-move-element.js → point-move-material.js} +6 -6
  65. package/dist/esm/view/point.d.ts +3 -8
  66. package/dist/esm/view/point.js +1 -21
  67. package/dist/esm/view/position.d.ts +9 -9
  68. package/dist/esm/view/position.js +1 -1
  69. package/dist/esm/view/rect.d.ts +2 -2
  70. package/dist/esm/view/rect.js +4 -4
  71. package/dist/esm/view/resize-material.d.ts +4 -0
  72. package/dist/esm/view/resize-material.js +266 -0
  73. package/dist/esm/view/rotate.d.ts +11 -11
  74. package/dist/esm/view/rotate.js +24 -24
  75. package/dist/esm/view/static.d.ts +13 -0
  76. package/dist/esm/view/static.js +89 -0
  77. package/dist/esm/view/styles.d.ts +11 -0
  78. package/dist/esm/view/styles.js +78 -0
  79. package/dist/esm/view/vertex.d.ts +8 -8
  80. package/dist/esm/view/vertex.js +28 -28
  81. package/dist/esm/view/view-box.d.ts +2 -6
  82. package/dist/esm/view/view-box.js +8 -64
  83. package/dist/esm/view/view-calc.d.ts +23 -20
  84. package/dist/esm/view/view-calc.js +104 -93
  85. package/dist/esm/view/view-content.d.ts +2 -2
  86. package/dist/esm/view/view-content.js +34 -34
  87. package/dist/index.global.js +3144 -1548
  88. package/dist/index.global.min.js +1 -1
  89. package/package.json +1 -1
  90. package/dist/esm/view/element.d.ts +0 -35
  91. package/dist/esm/view/element.js +0 -471
  92. package/dist/esm/view/handle-element.d.ts +0 -24
  93. package/dist/esm/view/point-move-element.d.ts +0 -5
  94. package/dist/esm/view/resize-element.d.ts +0 -4
  95. package/dist/esm/view/resize-element.js +0 -255
  96. package/dist/esm/view/svg-path.d.ts +0 -10
@@ -1,173 +1 @@
1
- import { is } from './is';
2
- export function elementToBoxInfo(elem) {
3
- const { x, y, w, h, detail } = elem;
4
- const { borderWidth, borderRadius, boxSizing } = detail;
5
- let btw = 0;
6
- let brw = 0;
7
- let bbw = 0;
8
- let blw = 0;
9
- let btlr = 0;
10
- let btrr = 0;
11
- let bblr = 0;
12
- let bbrr = 0;
13
- if (typeof borderWidth === 'number' && borderWidth > 0) {
14
- btw = borderWidth;
15
- brw = borderWidth;
16
- bbw = borderWidth;
17
- blw = borderWidth;
18
- }
19
- else if (Array.isArray(borderWidth)) {
20
- btw = is.positiveNum(borderWidth[0]) ? borderWidth[0] : 0;
21
- brw = is.positiveNum(borderWidth[1]) ? borderWidth[0] : 0;
22
- bbw = is.positiveNum(borderWidth[2]) ? borderWidth[0] : 0;
23
- blw = is.positiveNum(borderWidth[3]) ? borderWidth[0] : 0;
24
- }
25
- if (typeof borderRadius === 'number' && borderRadius > 0) {
26
- btlr = borderRadius;
27
- btrr = borderRadius;
28
- bblr = borderRadius;
29
- bbrr = borderRadius;
30
- }
31
- else if (Array.isArray(borderRadius)) {
32
- btlr = is.positiveNum(borderRadius[0]) ? borderRadius[0] : 0;
33
- btrr = is.positiveNum(borderRadius[0]) ? borderRadius[0] : 0;
34
- bblr = is.positiveNum(borderRadius[0]) ? borderRadius[0] : 0;
35
- bbrr = is.positiveNum(borderRadius[0]) ? borderRadius[0] : 0;
36
- }
37
- const p0 = { x: x, y: y };
38
- const p1 = { x: x + w, y: y };
39
- const p2 = { x: x + w, y: y + h };
40
- const p3 = { x: x, y: y + h };
41
- const p0s = { x: x, y: y + btlr };
42
- const p0e = { x: x + btlr, y: y };
43
- const p1s = { x: x + w - btrr, y: y };
44
- const p1e = { x: x + w, y: y + btrr };
45
- const p2s = { x: x + w, y: y + h - bbrr };
46
- const p2e = { x: x + w - bbrr, y: y + h };
47
- const p3s = { x: x + bblr, y: y + h };
48
- const p3e = { x: x, y: y + h - bblr };
49
- let op0 = Object.assign({}, p0);
50
- let op1 = Object.assign({}, p1);
51
- let op2 = Object.assign({}, p2);
52
- let op3 = Object.assign({}, p3);
53
- let op0s = Object.assign({}, p0s);
54
- let op0e = Object.assign({}, p0e);
55
- let op1s = Object.assign({}, p1s);
56
- let op1e = Object.assign({}, p1e);
57
- let op2s = Object.assign({}, p2s);
58
- let op2e = Object.assign({}, p2e);
59
- let op3s = Object.assign({}, p3s);
60
- let op3e = Object.assign({}, p3e);
61
- let ip0 = Object.assign({}, p0);
62
- let ip1 = Object.assign({}, p1);
63
- let ip2 = Object.assign({}, p2);
64
- let ip3 = Object.assign({}, p3);
65
- let ip0s = Object.assign({}, p0s);
66
- let ip0e = Object.assign({}, p0e);
67
- let ip1s = Object.assign({}, p1s);
68
- let ip1e = Object.assign({}, p1e);
69
- let ip2s = Object.assign({}, p2s);
70
- let ip2e = Object.assign({}, p2e);
71
- let ip3s = Object.assign({}, p3s);
72
- let ip3e = Object.assign({}, p3e);
73
- if (boxSizing === 'border-box') {
74
- ip0 = { x: ip0.x + blw, y: ip0.y + btw };
75
- ip1 = { x: ip1.x - brw, y: ip1.y + btw };
76
- ip2 = { x: ip2.x - brw, y: ip2.y - bbw };
77
- ip3 = { x: ip3.x + blw, y: ip3.y - bbw };
78
- ip0s = { x: ip0s.x + blw, y: ip0s.y + btw };
79
- ip0e = { x: ip0e.x + blw, y: ip0e.y + btw };
80
- ip1s = { x: ip1s.x - brw, y: ip1s.y + btw };
81
- ip1e = { x: ip1e.x - brw, y: ip1e.y + btw };
82
- ip2s = { x: ip2s.x - brw, y: ip2s.y - bbw };
83
- ip2e = { x: ip2e.x - brw, y: ip2e.y - bbw };
84
- ip3s = { x: ip3s.x + blw, y: ip3s.y - bbw };
85
- ip3e = { x: ip3e.x + blw, y: ip3e.y - bbw };
86
- }
87
- else if (boxSizing === 'content-box') {
88
- op0 = { x: op0.x - blw, y: op0.y - btw };
89
- op1 = { x: op1.x + brw, y: op1.y - btw };
90
- op2 = { x: op2.x + brw, y: op2.y + bbw };
91
- op3 = { x: op3.x - blw, y: op3.y + bbw };
92
- op0s = { x: op0s.x - blw, y: op0s.y - btw };
93
- op0e = { x: op0e.x - blw, y: op0e.y - btw };
94
- op1s = { x: op1s.x + brw, y: op1s.y - btw };
95
- op1e = { x: op1e.x + brw, y: op1e.y - btw };
96
- op2s = { x: op2s.x + brw, y: op2s.y + bbw };
97
- op2e = { x: op2e.x + brw, y: op2e.y + bbw };
98
- op3s = { x: op3s.x - blw, y: op3s.y + bbw };
99
- op3e = { x: op3e.x - blw, y: op3e.y + bbw };
100
- }
101
- else {
102
- ip0 = { x: ip0.x + blw / 2, y: ip0.y + btw / 2 };
103
- ip1 = { x: ip1.x - brw / 2, y: ip1.y + btw / 2 };
104
- ip2 = { x: ip2.x - brw / 2, y: ip2.y - bbw / 2 };
105
- ip3 = { x: ip3.x + blw / 2, y: ip3.y - bbw / 2 };
106
- ip0s = { x: ip0s.x + blw / 2, y: ip0s.y + btw / 2 };
107
- ip0e = { x: ip0e.x + blw / 2, y: ip0e.y + btw / 2 };
108
- ip1s = { x: ip1s.x - brw / 2, y: ip1s.y + btw / 2 };
109
- ip1e = { x: ip1e.x - brw / 2, y: ip1e.y + btw / 2 };
110
- ip2s = { x: ip2s.x - brw / 2, y: ip2s.y - bbw / 2 };
111
- ip2e = { x: ip2e.x - brw / 2, y: ip2e.y - bbw / 2 };
112
- ip3s = { x: ip3s.x + blw / 2, y: ip3s.y - bbw / 2 };
113
- ip3e = { x: ip3e.x + blw / 2, y: ip3e.y - bbw / 2 };
114
- op0 = { x: op0.x - blw / 2, y: op0.y - btw / 2 };
115
- op1 = { x: op1.x + brw / 2, y: op1.y - btw / 2 };
116
- op2 = { x: op2.x + brw / 2, y: op2.y + bbw / 2 };
117
- op3 = { x: op3.x - blw / 2, y: op3.y + bbw / 2 };
118
- op0s = { x: op0s.x - blw / 2, y: op0s.y - btw / 2 };
119
- op0e = { x: op0e.x - blw / 2, y: op0e.y - btw / 2 };
120
- op1s = { x: op1s.x + brw / 2, y: op1s.y - btw / 2 };
121
- op1e = { x: op1e.x + brw / 2, y: op1e.y - btw / 2 };
122
- op2s = { x: op2s.x + brw / 2, y: op2s.y + bbw / 2 };
123
- op2e = { x: op2e.x + brw / 2, y: op2e.y + bbw / 2 };
124
- op3s = { x: op3s.x - blw / 2, y: op3s.y + bbw / 2 };
125
- op3e = { x: op3e.x - blw / 2, y: op3e.y + bbw / 2 };
126
- }
127
- return {
128
- btw,
129
- brw,
130
- bbw,
131
- blw,
132
- btlr,
133
- btrr,
134
- bblr,
135
- bbrr,
136
- p0,
137
- p1,
138
- p2,
139
- p3,
140
- p0s,
141
- p0e,
142
- p1s,
143
- p1e,
144
- p2s,
145
- p2e,
146
- p3s,
147
- p3e,
148
- op0,
149
- op1,
150
- op2,
151
- op3,
152
- op0s,
153
- op0e,
154
- op1s,
155
- op1e,
156
- op2s,
157
- op2e,
158
- op3s,
159
- op3e,
160
- ip0,
161
- ip1,
162
- ip2,
163
- ip3,
164
- ip0s,
165
- ip0e,
166
- ip1s,
167
- ip1e,
168
- ip2s,
169
- ip2e,
170
- ip3s,
171
- ip3e
172
- };
173
- }
1
+ "use strict";
@@ -18,7 +18,7 @@ export function createOffscreenContext2D(opts) {
18
18
  const offCtx = offRenderCtx.canvas.getContext('2d');
19
19
  const context2d = new Context2D(offCtx, {
20
20
  devicePixelRatio,
21
- offscreenCanvas: offCanvas
21
+ offscreenCanvas: offCanvas,
22
22
  });
23
23
  return context2d;
24
24
  }
@@ -27,7 +27,7 @@ export function createBoardContent(canvas, opts) {
27
27
  const ctxOpts = {
28
28
  width,
29
29
  height,
30
- devicePixelRatio
30
+ devicePixelRatio,
31
31
  };
32
32
  const ctx = canvas.getContext('2d');
33
33
  const viewContext = createOffscreenContext2D(ctxOpts);
@@ -51,7 +51,7 @@ export function createBoardContent(canvas, opts) {
51
51
  overlayContext,
52
52
  boardContext,
53
53
  tempContext,
54
- drawView
54
+ drawView,
55
55
  };
56
56
  return content;
57
57
  }
@@ -1,10 +1,11 @@
1
- declare function attrs(attrs: any): boolean;
2
- declare function rectDesc(detail: any): boolean;
3
- declare function circleDesc(detail: any): boolean;
4
- declare function imageDesc(detail: any): boolean;
5
- declare function svgDesc(detail: any): boolean;
6
- declare function htmlDesc(detail: any): boolean;
7
- declare function textDesc(detail: any): boolean;
1
+ import { MaterialSize } from '@idraw/types';
2
+ declare function attrs(attrs: MaterialSize): boolean;
3
+ declare function rectDesc(attributes: any): boolean;
4
+ declare function circleDesc(attributes: any): boolean;
5
+ declare function imageDesc(attributes: any): boolean;
6
+ declare function svgDesc(attributes: any): boolean;
7
+ declare function htmlDesc(attributes: any): boolean;
8
+ declare function textDesc(attributes: any): boolean;
8
9
  export declare const check: {
9
10
  attrs: typeof attrs;
10
11
  textDesc: typeof textDesc;
@@ -1,7 +1,7 @@
1
1
  import { is } from './is';
2
2
  function attrs(attrs) {
3
- const { x, y, w, h, angle } = attrs;
4
- if (!(is.x(x) && is.y(y) && is.w(w) && is.h(h) && is.angle(angle))) {
3
+ const { x, y, width, height, angle = 0 } = attrs;
4
+ if (!(is.x(x) && is.y(y) && is.width(width) && is.height(height) && is.angle(angle))) {
5
5
  return false;
6
6
  }
7
7
  if (!(angle >= -360 && angle <= 360)) {
@@ -9,65 +9,65 @@ function attrs(attrs) {
9
9
  }
10
10
  return true;
11
11
  }
12
- function box(detail = {}) {
13
- const { borderColor, borderRadius, borderWidth } = detail;
14
- if (Object.prototype.hasOwnProperty.call(detail, 'borderColor') && !is.color(borderColor)) {
12
+ function box(attributes = {}) {
13
+ const { stroke, cornerRadius, strokeWidth } = attributes;
14
+ if (Object.prototype.hasOwnProperty.call(attributes, 'stroke') && !is.color(stroke)) {
15
15
  return false;
16
16
  }
17
- if (Object.prototype.hasOwnProperty.call(detail, 'borderRadius') && !is.number(borderRadius)) {
17
+ if (Object.prototype.hasOwnProperty.call(attributes, 'cornerRadius') && !is.number(cornerRadius)) {
18
18
  return false;
19
19
  }
20
- if (Object.prototype.hasOwnProperty.call(detail, 'borderWidth') && !is.number(borderWidth)) {
20
+ if (Object.prototype.hasOwnProperty.call(attributes, 'strokeWidth') && !is.number(strokeWidth)) {
21
21
  return false;
22
22
  }
23
23
  return true;
24
24
  }
25
- function rectDesc(detail) {
26
- const { background } = detail;
27
- if (Object.prototype.hasOwnProperty.call(detail, 'background') && !is.color(background)) {
25
+ function rectDesc(attributes) {
26
+ const { background } = attributes;
27
+ if (Object.prototype.hasOwnProperty.call(attributes, 'background') && !is.color(background)) {
28
28
  return false;
29
29
  }
30
- if (!box(detail)) {
30
+ if (!box(attributes)) {
31
31
  return false;
32
32
  }
33
33
  return true;
34
34
  }
35
- function circleDesc(detail) {
36
- const { background, borderColor, borderWidth } = detail;
37
- if (Object.prototype.hasOwnProperty.call(detail, 'background') && !is.color(background)) {
35
+ function circleDesc(attributes) {
36
+ const { background, stroke, strokeWidth } = attributes;
37
+ if (Object.prototype.hasOwnProperty.call(attributes, 'background') && !is.color(background)) {
38
38
  return false;
39
39
  }
40
- if (Object.prototype.hasOwnProperty.call(detail, 'borderColor') && !is.color(borderColor)) {
40
+ if (Object.prototype.hasOwnProperty.call(attributes, 'stroke') && !is.color(stroke)) {
41
41
  return false;
42
42
  }
43
- if (Object.prototype.hasOwnProperty.call(detail, 'borderWidth') && !is.number(borderWidth)) {
43
+ if (Object.prototype.hasOwnProperty.call(attributes, 'strokeWidth') && !is.number(strokeWidth)) {
44
44
  return false;
45
45
  }
46
46
  return true;
47
47
  }
48
- function imageDesc(detail) {
49
- const { src } = detail;
50
- if (!is.imageSrc(src)) {
48
+ function imageDesc(attributes) {
49
+ const { href } = attributes;
50
+ if (!is.imageSrc(href)) {
51
51
  return false;
52
52
  }
53
53
  return true;
54
54
  }
55
- function svgDesc(detail) {
56
- const { svg } = detail;
55
+ function svgDesc(attributes) {
56
+ const { svg } = attributes;
57
57
  if (!is.svg(svg)) {
58
58
  return false;
59
59
  }
60
60
  return true;
61
61
  }
62
- function htmlDesc(detail) {
63
- const { html } = detail;
62
+ function htmlDesc(attributes) {
63
+ const { html } = attributes;
64
64
  if (!is.html(html)) {
65
65
  return false;
66
66
  }
67
67
  return true;
68
68
  }
69
- function textDesc(detail) {
70
- const { text, color, fontSize, lineHeight, fontFamily, textAlign, fontWeight, background, strokeWidth, strokeColor } = detail;
69
+ function textDesc(attributes) {
70
+ const { text, color, fontSize, lineHeight, fontFamily, textAlign, fontWeight, background, strokeWidth, strokeColor } = attributes;
71
71
  if (!is.text(text)) {
72
72
  return false;
73
73
  }
@@ -77,28 +77,28 @@ function textDesc(detail) {
77
77
  if (!is.fontSize(fontSize)) {
78
78
  return false;
79
79
  }
80
- if (Object.prototype.hasOwnProperty.call(detail, 'background') && !is.color(background)) {
80
+ if (Object.prototype.hasOwnProperty.call(attributes, 'background') && !is.color(background)) {
81
81
  return false;
82
82
  }
83
- if (Object.prototype.hasOwnProperty.call(detail, 'fontWeight') && !is.fontWeight(fontWeight)) {
83
+ if (Object.prototype.hasOwnProperty.call(attributes, 'fontWeight') && !is.fontWeight(fontWeight)) {
84
84
  return false;
85
85
  }
86
- if (Object.prototype.hasOwnProperty.call(detail, 'lineHeight') && !is.lineHeight(lineHeight)) {
86
+ if (Object.prototype.hasOwnProperty.call(attributes, 'lineHeight') && !is.lineHeight(lineHeight)) {
87
87
  return false;
88
88
  }
89
- if (Object.prototype.hasOwnProperty.call(detail, 'fontFamily') && !is.fontFamily(fontFamily)) {
89
+ if (Object.prototype.hasOwnProperty.call(attributes, 'fontFamily') && !is.fontFamily(fontFamily)) {
90
90
  return false;
91
91
  }
92
- if (Object.prototype.hasOwnProperty.call(detail, 'textAlign') && !is.textAlign(textAlign)) {
92
+ if (Object.prototype.hasOwnProperty.call(attributes, 'textAlign') && !is.textAlign(textAlign)) {
93
93
  return false;
94
94
  }
95
- if (Object.prototype.hasOwnProperty.call(detail, 'strokeWidth') && !is.strokeWidth(strokeWidth)) {
95
+ if (Object.prototype.hasOwnProperty.call(attributes, 'strokeWidth') && !is.strokeWidth(strokeWidth)) {
96
96
  return false;
97
97
  }
98
- if (Object.prototype.hasOwnProperty.call(detail, 'strokeColor') && !is.color(strokeColor)) {
98
+ if (Object.prototype.hasOwnProperty.call(attributes, 'strokeColor') && !is.color(strokeColor)) {
99
99
  return false;
100
100
  }
101
- if (!box(detail)) {
101
+ if (!box(attributes)) {
102
102
  return false;
103
103
  }
104
104
  return true;
@@ -110,5 +110,5 @@ export const check = {
110
110
  circleDesc,
111
111
  imageDesc,
112
112
  svgDesc,
113
- htmlDesc
113
+ htmlDesc,
114
114
  };
@@ -1,9 +0,0 @@
1
- import type { DefaultElementDetailConfig, ElementSize, ElementRectDetail, ElementCircleDetail, ElementTextDetail, ElementSVGDetail, ElementImageDetail, ElementGroupDetail } from '@idraw/types';
2
- export declare const defaultText = "Text Element";
3
- export declare function getDefaultElementDetailConfig(): DefaultElementDetailConfig;
4
- export declare function getDefaultElementRectDetail(): ElementRectDetail;
5
- export declare function getDefaultElementCircleDetail(): ElementCircleDetail;
6
- export declare function getDefaultElementTextDetail(elementSize: ElementSize): ElementTextDetail;
7
- export declare function getDefaultElementSVGDetail(): ElementSVGDetail;
8
- export declare function getDefaultElementImageDetail(): ElementImageDetail;
9
- export declare function getDefaultElementGroupDetail(): ElementGroupDetail;
@@ -1,71 +1 @@
1
- export const defaultText = 'Text Element';
2
- export function getDefaultElementDetailConfig() {
3
- const config = {
4
- boxSizing: 'border-box',
5
- borderWidth: 0,
6
- borderColor: '#000000',
7
- shadowColor: '#000000',
8
- borderRadius: 0,
9
- borderDash: [],
10
- shadowOffsetX: 0,
11
- shadowOffsetY: 0,
12
- shadowBlur: 0,
13
- opacity: 1,
14
- color: '#000000',
15
- textAlign: 'left',
16
- verticalAlign: 'top',
17
- fontSize: 16,
18
- fontFamily: 'sans-serif',
19
- fontWeight: 400,
20
- minInlineSize: 'auto',
21
- wordBreak: 'break-all',
22
- overflow: 'hidden'
23
- };
24
- return config;
25
- }
26
- export function getDefaultElementRectDetail() {
27
- const detail = {
28
- background: '#D9D9D9'
29
- };
30
- return detail;
31
- }
32
- export function getDefaultElementCircleDetail() {
33
- const detail = {
34
- background: '#D9D9D9',
35
- radius: 0
36
- };
37
- return detail;
38
- }
39
- export function getDefaultElementTextDetail(elementSize) {
40
- const detailConfig = getDefaultElementDetailConfig();
41
- const detail = {
42
- text: defaultText,
43
- color: detailConfig.color,
44
- fontFamily: detailConfig.fontFamily,
45
- fontWeight: detailConfig.fontWeight,
46
- fontSize: elementSize.w / defaultText.length,
47
- textAlign: 'center',
48
- verticalAlign: 'middle'
49
- };
50
- return detail;
51
- }
52
- export function getDefaultElementSVGDetail() {
53
- const detail = {
54
- svg: '<svg t="1701004189871" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3-12.3 12.7-12.1 32.9 0.6 45.3l183.7 179.1-43.4 252.9c-1.2 6.9-0.1 14.1 3.2 20.3 8.2 15.6 27.6 21.7 43.2 13.4L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3zM664.8 561.6l36.1 210.3L512 672.7 323.1 772l36.1-210.3-152.8-149L417.6 382 512 190.7 606.4 382l211.2 30.7-152.8 148.9z" fill="#2c2c2c"></path></svg>'
55
- };
56
- return detail;
57
- }
58
- export function getDefaultElementImageDetail() {
59
- const detail = {
60
- src: 'data:image/svg+xml;base64,PHN2ZyAgIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiPjxwYXRoIGQ9Ik05MjggMTYwSDk2Yy0xNy43IDAtMzIgMTQuMy0zMiAzMnY2NDBjMCAxNy43IDE0LjMgMzIgMzIgMzJoODMyYzE3LjcgMCAzMi0xNC4zIDMyLTMyVjE5MmMwLTE3LjctMTQuMy0zMi0zMi0zMnogbS00MCA2MzJIMTM2di0zOS45bDEzOC41LTE2NC4zIDE1MC4xIDE3OEw2NTguMSA0ODkgODg4IDc2MS42Vjc5MnogbTAtMTI5LjhMNjY0LjIgMzk2LjhjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDQyNC42IDY2Ni40bC0xNDQtMTcwLjdjLTMuMi0zLjgtOS0zLjgtMTIuMiAwTDEzNiA2NTIuN1YyMzJoNzUydjQzMC4yeiIgIGZpbGw9IiM1MTUxNTEiPjwvcGF0aD48cGF0aCBkPSJNMzA0IDQ1NmM0OC42IDAgODgtMzkuNCA4OC04OHMtMzkuNC04OC04OC04OC04OCAzOS40LTg4IDg4IDM5LjQgODggODggODh6IG0wLTExNmMxNS41IDAgMjggMTIuNSAyOCAyOHMtMTIuNSAyOC0yOCAyOC0yOC0xMi41LTI4LTI4IDEyLjUtMjggMjgtMjh6IiAgZmlsbD0iIzUxNTE1MSI+PC9wYXRoPjwvc3ZnPg=='
61
- };
62
- return detail;
63
- }
64
- export function getDefaultElementGroupDetail() {
65
- const detail = {
66
- children: [],
67
- background: '#D9D9D9',
68
- overflow: 'hidden'
69
- };
70
- return detail;
71
- }
1
+ "use strict";
@@ -47,9 +47,15 @@ export declare class Context2D implements ViewContext2D {
47
47
  set shadowBlur(blur: number);
48
48
  get lineCap(): CanvasLineCap;
49
49
  set lineCap(lineCap: CanvasLineCap);
50
+ get lineJoin(): CanvasLineJoin;
51
+ set lineJoin(lineJoin: CanvasLineJoin);
52
+ get lineDashOffset(): number;
53
+ set lineDashOffset(lineDashOffset: number);
54
+ get miterLimit(): number;
55
+ set miterLimit(miterLimit: number);
50
56
  get globalCompositeOperation(): GlobalCompositeOperation;
51
57
  set globalCompositeOperation(operations: GlobalCompositeOperation);
52
- fill(...args: [fillRule?: CanvasFillRule | undefined] | [path: Path2D, fillRule?: CanvasFillRule | undefined]): void;
58
+ fill(...params: [fillRule?: CanvasFillRule | undefined] | [path: Path2D, fillRule?: CanvasFillRule | undefined]): void;
53
59
  arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean | undefined): void;
54
60
  rect(x: number, y: number, w: number, h: number): void;
55
61
  fillRect(x: number, y: number, w: number, h: number): void;
@@ -66,7 +72,7 @@ export declare class Context2D implements ViewContext2D {
66
72
  stroke(path?: Path2D): void;
67
73
  translate(x: number, y: number): void;
68
74
  rotate(angle: number): void;
69
- drawImage(...args: any[]): void;
75
+ drawImage(...params: any[]): void;
70
76
  createPattern(image: CanvasImageSource, repetition: string | null): CanvasPattern | null;
71
77
  measureText(text: string): TextMetrics;
72
78
  fillText(text: string, x: number, y: number, maxWidth?: number | undefined): void;
@@ -75,8 +81,9 @@ export declare class Context2D implements ViewContext2D {
75
81
  restore(): void;
76
82
  scale(ratioX: number, ratioY: number): void;
77
83
  circle(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean | undefined): void;
84
+ ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
78
85
  isPointInPath(x: number, y: number): boolean;
79
- clip(...args: [fillRule?: CanvasFillRule | undefined] | [path: Path2D, fillRule?: CanvasFillRule | undefined]): void;
86
+ clip(...params: [fillRule?: CanvasFillRule | undefined] | [path: Path2D, fillRule?: CanvasFillRule | undefined]): void;
80
87
  setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
81
88
  getTransform(): DOMMatrix2DInit;
82
89
  createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient;
@@ -46,7 +46,7 @@ export class Context2D {
46
46
  this.$setFont({
47
47
  fontSize: defaultFontSize,
48
48
  fontFamily: defaultFontFamily,
49
- fontWeight: defaultFontWeight
49
+ fontWeight: defaultFontWeight,
50
50
  });
51
51
  }
52
52
  $getOffscreenCanvas() {
@@ -58,7 +58,7 @@ export class Context2D {
58
58
  canvas.width = width * devicePixelRatio;
59
59
  canvas.height = height * devicePixelRatio;
60
60
  __classPrivateFieldSet(this, _Context2D_opts, Object.assign(Object.assign({}, __classPrivateFieldGet(this, _Context2D_opts, "f")), {
61
- devicePixelRatio
61
+ devicePixelRatio,
62
62
  }), "f");
63
63
  if (resetStyle === true) {
64
64
  canvas.style.width = `${width}px`;
@@ -71,7 +71,7 @@ export class Context2D {
71
71
  return {
72
72
  width: width / devicePixelRatio,
73
73
  height: height / devicePixelRatio,
74
- devicePixelRatio
74
+ devicePixelRatio,
75
75
  };
76
76
  }
77
77
  get canvas() {
@@ -143,14 +143,32 @@ export class Context2D {
143
143
  set lineCap(lineCap) {
144
144
  __classPrivateFieldGet(this, _Context2D_ctx, "f").lineCap = lineCap;
145
145
  }
146
+ get lineJoin() {
147
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").lineJoin;
148
+ }
149
+ set lineJoin(lineJoin) {
150
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").lineJoin = lineJoin;
151
+ }
152
+ get lineDashOffset() {
153
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").lineDashOffset;
154
+ }
155
+ set lineDashOffset(lineDashOffset) {
156
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").lineDashOffset = lineDashOffset;
157
+ }
158
+ get miterLimit() {
159
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").miterLimit;
160
+ }
161
+ set miterLimit(miterLimit) {
162
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").miterLimit = miterLimit;
163
+ }
146
164
  get globalCompositeOperation() {
147
165
  return __classPrivateFieldGet(this, _Context2D_ctx, "f").globalCompositeOperation;
148
166
  }
149
167
  set globalCompositeOperation(operations) {
150
168
  __classPrivateFieldGet(this, _Context2D_ctx, "f").globalCompositeOperation = operations;
151
169
  }
152
- fill(...args) {
153
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").fill(...args);
170
+ fill(...params) {
171
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").fill(...params);
154
172
  }
155
173
  arc(x, y, radius, startAngle, endAngle, anticlockwise) {
156
174
  return __classPrivateFieldGet(this, _Context2D_ctx, "f").arc(this.$doPixelRatio(x), this.$doPixelRatio(y), this.$doPixelRatio(radius), startAngle, endAngle, anticlockwise);
@@ -201,17 +219,17 @@ export class Context2D {
201
219
  rotate(angle) {
202
220
  return __classPrivateFieldGet(this, _Context2D_ctx, "f").rotate(angle);
203
221
  }
204
- drawImage(...args) {
205
- const image = args[0];
206
- const sx = args[1];
207
- const sy = args[2];
208
- const sw = args[3];
209
- const sh = args[4];
210
- const dx = args[args.length - 4];
211
- const dy = args[args.length - 3];
212
- const dw = args[args.length - 2];
213
- const dh = args[args.length - 1];
214
- if (args.length === 9) {
222
+ drawImage(...params) {
223
+ const image = params[0];
224
+ const sx = params[1];
225
+ const sy = params[2];
226
+ const sw = params[3];
227
+ const sh = params[4];
228
+ const dx = params[params.length - 4];
229
+ const dy = params[params.length - 3];
230
+ const dw = params[params.length - 2];
231
+ const dh = params[params.length - 1];
232
+ if (params.length === 9) {
215
233
  return __classPrivateFieldGet(this, _Context2D_ctx, "f").drawImage(image, this.$doPixelRatio(sx), this.$doPixelRatio(sy), this.$doPixelRatio(sw), this.$doPixelRatio(sh), this.$doPixelRatio(dx), this.$doPixelRatio(dy), this.$doPixelRatio(dw), this.$doPixelRatio(dh));
216
234
  }
217
235
  else {
@@ -253,11 +271,14 @@ export class Context2D {
253
271
  circle(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
254
272
  __classPrivateFieldGet(this, _Context2D_ctx, "f").ellipse(this.$doPixelRatio(x), this.$doPixelRatio(y), this.$doPixelRatio(radiusX), this.$doPixelRatio(radiusY), rotation, startAngle, endAngle, counterclockwise);
255
273
  }
274
+ ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
275
+ __classPrivateFieldGet(this, _Context2D_ctx, "f").ellipse(this.$doPixelRatio(x), this.$doPixelRatio(y), this.$doPixelRatio(radiusX), this.$doPixelRatio(radiusY), rotation, startAngle, endAngle, counterclockwise);
276
+ }
256
277
  isPointInPath(x, y) {
257
278
  return __classPrivateFieldGet(this, _Context2D_ctx, "f").isPointInPath(this.$doPixelRatio(x), this.$doPixelRatio(y));
258
279
  }
259
- clip(...args) {
260
- return __classPrivateFieldGet(this, _Context2D_ctx, "f").clip(...args);
280
+ clip(...params) {
281
+ return __classPrivateFieldGet(this, _Context2D_ctx, "f").clip(...params);
261
282
  }
262
283
  setTransform(a, b, c, d, e, f) {
263
284
  return __classPrivateFieldGet(this, _Context2D_ctx, "f").setTransform(a, b, c, d, e, f);
@@ -1,12 +1,12 @@
1
- import type { Element, ElementSize, ElementSizeController, ViewScaleInfo, LayoutSizeController } from '@idraw/types';
2
- export declare function calcElementSizeController(elemSize: ElementSize, opts: {
3
- groupQueue: Element<'group'>[];
1
+ import type { StrictMaterial, MaterialSize, MaterialSizeController, ViewScaleInfo, LayoutSizeController } from '@idraw/types';
2
+ export declare function calcMaterialSizeController(mtrlSize: MaterialSize, opts: {
3
+ groupQueue: StrictMaterial<'group'>[];
4
4
  controllerSize: number;
5
5
  rotateControllerSize: number;
6
6
  rotateControllerPosition: number;
7
7
  viewScaleInfo: ViewScaleInfo;
8
- }): ElementSizeController;
9
- export declare function calcLayoutSizeController(layoutSize: Pick<ElementSize, 'x' | 'y' | 'w' | 'h'>, opts: {
8
+ }): MaterialSizeController;
9
+ export declare function calcLayoutSizeController(layoutSize: Pick<MaterialSize, 'x' | 'y' | 'width' | 'height'>, opts: {
10
10
  controllerSize?: number;
11
11
  viewScaleInfo: ViewScaleInfo;
12
12
  }): LayoutSizeController;