@_unit/unit 1.0.23 → 1.0.24
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/build/web.js +10 -10
- package/lib/API.d.ts +1 -0
- package/lib/client/PositionObserver.js +55 -18
- package/lib/client/PositionObserver.js.map +1 -1
- package/lib/client/platform/web/api/window.js +3 -0
- package/lib/client/platform/web/api/window.js.map +1 -1
- package/lib/host/none.js +3 -0
- package/lib/host/none.js.map +1 -1
- package/lib/system/_classes.d.ts +2 -0
- package/lib/system/_classes.js +2 -0
- package/lib/system/_classes.js.map +1 -1
- package/lib/system/_components.d.ts +2 -0
- package/lib/system/_components.js +44 -42
- package/lib/system/_components.js.map +1 -1
- package/lib/system/_ids.d.ts +1 -0
- package/lib/system/_ids.js +8 -7
- package/lib/system/_ids.js.map +1 -1
- package/lib/system/_specs.js +1 -1
- package/lib/system/_specs.js.map +1 -1
- package/lib/system/platform/component/svg/Object/Component.d.ts +23 -0
- package/lib/system/platform/component/svg/Object/Component.js +82 -0
- package/lib/system/platform/component/svg/Object/Component.js.map +1 -0
- package/lib/system/platform/component/svg/Object/index.d.ts +13 -0
- package/lib/system/platform/component/svg/Object/index.js +17 -0
- package/lib/system/platform/component/svg/Object/index.js.map +1 -0
- package/lib/types/global/IPositionObserver.d.ts +5 -1
- package/package.json +1 -1
- package/public/_worker.js +5 -5
- package/public/_worker.js.map +4 -4
- package/public/build.json +1 -1
- package/public/index.js +10 -10
- package/public/index.js.map +4 -4
- package/src/API.ts +1 -0
- package/src/client/PositionObserver.ts +72 -15
- package/src/client/platform/web/api/window.ts +4 -1
- package/src/host/none.ts +3 -0
- package/src/system/_classes.ts +2 -0
- package/src/system/_components.ts +2 -0
- package/src/system/_ids.ts +1 -0
- package/src/system/_specs.ts +1 -1
- package/src/system/platform/component/svg/Object/Component.ts +107 -0
- package/src/system/platform/component/svg/Object/index.ts +30 -0
- package/src/system/platform/component/svg/Object/spec.json +37 -0
- package/src/types/global/IPositionObserver.ts +9 -1
package/src/API.ts
CHANGED
|
@@ -201,6 +201,7 @@ export type API = {
|
|
|
201
201
|
}
|
|
202
202
|
ReadableStream: ReadableStream
|
|
203
203
|
open: (url: string, target: string, features: string) => Window
|
|
204
|
+
getComputedStyle: (element: Element) => CSSStyleDeclaration
|
|
204
205
|
}
|
|
205
206
|
document: {
|
|
206
207
|
createElement<K extends keyof HTMLElementTagNameMap>(
|
|
@@ -33,6 +33,7 @@ export class PositionObserver implements IPositionObserver {
|
|
|
33
33
|
|
|
34
34
|
const {
|
|
35
35
|
api: {
|
|
36
|
+
window: { getComputedStyle },
|
|
36
37
|
document: { MutationObserver, ResizeObserver },
|
|
37
38
|
animation: { requestAnimationFrame, cancelAnimationFrame },
|
|
38
39
|
},
|
|
@@ -63,6 +64,12 @@ export class PositionObserver implements IPositionObserver {
|
|
|
63
64
|
let px: number = 0
|
|
64
65
|
let py: number = 0
|
|
65
66
|
|
|
67
|
+
let gpx: number = 0
|
|
68
|
+
let gpy: number = 0
|
|
69
|
+
|
|
70
|
+
let gbx: number = 0
|
|
71
|
+
let gby: number = 0
|
|
72
|
+
|
|
66
73
|
let width: number = 0
|
|
67
74
|
let height: number = 0
|
|
68
75
|
|
|
@@ -82,6 +89,15 @@ export class PositionObserver implements IPositionObserver {
|
|
|
82
89
|
let parent_x: number = 0
|
|
83
90
|
let parent_y: number = 0
|
|
84
91
|
|
|
92
|
+
let parent_px: number = 0
|
|
93
|
+
let parent_py: number = 0
|
|
94
|
+
|
|
95
|
+
let parent_gpx: number = 0
|
|
96
|
+
let parent_gpy: number = 0
|
|
97
|
+
|
|
98
|
+
let parent_gbx: number = 0
|
|
99
|
+
let parent_gby: number = 0
|
|
100
|
+
|
|
85
101
|
let parent_scroll_top = 0
|
|
86
102
|
let parent_scroll_left = 0
|
|
87
103
|
|
|
@@ -93,7 +109,14 @@ export class PositionObserver implements IPositionObserver {
|
|
|
93
109
|
let parent_rz = 0
|
|
94
110
|
|
|
95
111
|
let _transform: string | undefined
|
|
96
|
-
let
|
|
112
|
+
let _borderWidth: string | undefined
|
|
113
|
+
let _padding: string | undefined
|
|
114
|
+
|
|
115
|
+
let _border_x: number = 0
|
|
116
|
+
let _border_y: number = 0
|
|
117
|
+
|
|
118
|
+
let _padding_x: number = 0
|
|
119
|
+
let _padding_y: number = 0
|
|
97
120
|
|
|
98
121
|
function _update_local(): void {
|
|
99
122
|
__update_local()
|
|
@@ -108,7 +131,9 @@ export class PositionObserver implements IPositionObserver {
|
|
|
108
131
|
offset_x = offsetLeft
|
|
109
132
|
offset_y = offsetTop
|
|
110
133
|
|
|
111
|
-
const { transform,
|
|
134
|
+
const { transform, padding } = style
|
|
135
|
+
|
|
136
|
+
const { borderWidth } = getComputedStyle(element)
|
|
112
137
|
|
|
113
138
|
if (
|
|
114
139
|
transform !== _transform ||
|
|
@@ -145,9 +170,9 @@ export class PositionObserver implements IPositionObserver {
|
|
|
145
170
|
_transform = transform
|
|
146
171
|
}
|
|
147
172
|
|
|
148
|
-
if (
|
|
149
|
-
if (
|
|
150
|
-
const [borderSizeStr] =
|
|
173
|
+
if (borderWidth !== _borderWidth) {
|
|
174
|
+
if (borderWidth) {
|
|
175
|
+
const [borderSizeStr] = borderWidth.split(' ')
|
|
151
176
|
|
|
152
177
|
let borderSize = 0
|
|
153
178
|
|
|
@@ -157,13 +182,33 @@ export class PositionObserver implements IPositionObserver {
|
|
|
157
182
|
borderSize = applyLayoutValue(borderSizeStr, 0)
|
|
158
183
|
}
|
|
159
184
|
|
|
160
|
-
|
|
161
|
-
|
|
185
|
+
_border_x = borderSize
|
|
186
|
+
_border_y = borderSize
|
|
162
187
|
}
|
|
163
188
|
|
|
164
|
-
|
|
189
|
+
_borderWidth = borderWidth
|
|
165
190
|
}
|
|
166
191
|
|
|
192
|
+
if (padding !== _padding) {
|
|
193
|
+
const [paddingSizeStr] = padding.split(' ')
|
|
194
|
+
|
|
195
|
+
const paddingSize = applyLayoutValue(paddingSizeStr, 0)
|
|
196
|
+
|
|
197
|
+
_padding_x = paddingSize
|
|
198
|
+
_padding_y = paddingSize
|
|
199
|
+
|
|
200
|
+
_padding = padding
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
px = _border_x
|
|
204
|
+
py = _border_y
|
|
205
|
+
|
|
206
|
+
gpx = -parent_gpx + _padding_x
|
|
207
|
+
gpy = -parent_gpy + _padding_y
|
|
208
|
+
|
|
209
|
+
gbx = parent_px - parent_gbx
|
|
210
|
+
gby = parent_py - parent_gby
|
|
211
|
+
|
|
167
212
|
width = offsetWidth
|
|
168
213
|
height = offsetHeight
|
|
169
214
|
}
|
|
@@ -195,8 +240,8 @@ export class PositionObserver implements IPositionObserver {
|
|
|
195
240
|
const parent_rz_cos = Math.cos(parent_rz)
|
|
196
241
|
const parent_rz_sin = Math.sin(parent_rz)
|
|
197
242
|
|
|
198
|
-
const local_x = offset_x + transform_x
|
|
199
|
-
const local_y = offset_y + transform_y
|
|
243
|
+
const local_x = offset_x + transform_x - parent_gpx
|
|
244
|
+
const local_y = offset_y + transform_y - parent_gpy
|
|
200
245
|
|
|
201
246
|
const parent_scaled_local_x = local_x * parent_scale_x
|
|
202
247
|
const parent_scaled_local_y = local_y * parent_scale_y
|
|
@@ -209,12 +254,14 @@ export class PositionObserver implements IPositionObserver {
|
|
|
209
254
|
parent_scaled_local_x * parent_rz_sin
|
|
210
255
|
|
|
211
256
|
const px =
|
|
257
|
+
-parent_gbx +
|
|
212
258
|
parent_x -
|
|
213
259
|
parent_scroll_left +
|
|
214
260
|
parent_scaled_rotated_local_x * scale_x -
|
|
215
261
|
((width * parent_scale_x) / 2) * (scale_x - 1)
|
|
216
262
|
|
|
217
263
|
const py =
|
|
264
|
+
-parent_gby +
|
|
218
265
|
parent_y -
|
|
219
266
|
parent_scroll_top +
|
|
220
267
|
parent_scaled_rotated_local_y * scale_y -
|
|
@@ -245,7 +292,7 @@ export class PositionObserver implements IPositionObserver {
|
|
|
245
292
|
const update = (): void => {
|
|
246
293
|
_update()
|
|
247
294
|
|
|
248
|
-
this._callback(x, y, sx, sy, rx, ry, rz, px, py)
|
|
295
|
+
this._callback(x, y, sx, sy, rx, ry, rz, px, py, gpx, gpy, gbx, gby)
|
|
249
296
|
}
|
|
250
297
|
|
|
251
298
|
const mutationConfig = {
|
|
@@ -379,10 +426,20 @@ export class PositionObserver implements IPositionObserver {
|
|
|
379
426
|
ry: number,
|
|
380
427
|
rz: number,
|
|
381
428
|
px: number,
|
|
382
|
-
py: number
|
|
429
|
+
py: number,
|
|
430
|
+
gpx: number,
|
|
431
|
+
gpy: number,
|
|
432
|
+
gbx: number,
|
|
433
|
+
gby: number
|
|
383
434
|
) {
|
|
384
|
-
parent_x = x
|
|
385
|
-
parent_y = y
|
|
435
|
+
parent_x = x
|
|
436
|
+
parent_y = y
|
|
437
|
+
parent_px = px
|
|
438
|
+
parent_py = py
|
|
439
|
+
parent_gpx = gpx
|
|
440
|
+
parent_gpy = gpy
|
|
441
|
+
parent_gbx = gbx
|
|
442
|
+
parent_gby = gby
|
|
386
443
|
parent_scale_x = sx
|
|
387
444
|
parent_scale_y = sy
|
|
388
445
|
parent_rx = rx
|
|
@@ -447,7 +504,7 @@ export class PositionObserver implements IPositionObserver {
|
|
|
447
504
|
__update_local()
|
|
448
505
|
_update()
|
|
449
506
|
|
|
450
|
-
return { x, y, sx, sy, rx, ry, rz, px, py }
|
|
507
|
+
return { x, y, sx, sy, rx, ry, rz, px, py, gpx, gpy, gbx, gby }
|
|
451
508
|
}
|
|
452
509
|
|
|
453
510
|
disconnect() {
|
|
@@ -2,7 +2,7 @@ import { API } from '../../../../API'
|
|
|
2
2
|
import { BootOpt } from '../../../../system'
|
|
3
3
|
|
|
4
4
|
export function webWindow(window: Window, opt: BootOpt): API['window'] {
|
|
5
|
-
const _window = {
|
|
5
|
+
const _window: API['window'] = {
|
|
6
6
|
// @ts-ignore
|
|
7
7
|
AudioContext: window.AudioContext,
|
|
8
8
|
// @ts-ignore
|
|
@@ -26,6 +26,9 @@ export function webWindow(window: Window, opt: BootOpt): API['window'] {
|
|
|
26
26
|
open(url: string, target: string, features: string) {
|
|
27
27
|
return window.open(url, target, features)
|
|
28
28
|
},
|
|
29
|
+
getComputedStyle(element: Element): CSSStyleDeclaration {
|
|
30
|
+
return window.getComputedStyle(element)
|
|
31
|
+
},
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
return _window
|
package/src/host/none.ts
CHANGED
|
@@ -289,6 +289,9 @@ export function noHost(): API {
|
|
|
289
289
|
CompressionStream: undefined,
|
|
290
290
|
DecompressionStream: undefined,
|
|
291
291
|
ReadableStream: undefined,
|
|
292
|
+
getComputedStyle: function (element: Element): CSSStyleDeclaration {
|
|
293
|
+
throw new MethodNotImplementedError()
|
|
294
|
+
},
|
|
292
295
|
},
|
|
293
296
|
navigator: {
|
|
294
297
|
share: function (data: ShareData): Promise<void> {
|
package/src/system/_classes.ts
CHANGED
|
@@ -282,6 +282,7 @@ import ForeignObject from './platform/component/svg/ForeignObject'
|
|
|
282
282
|
import Group from './platform/component/svg/Group'
|
|
283
283
|
import Line from './platform/component/svg/Line'
|
|
284
284
|
import Marker from './platform/component/svg/Marker'
|
|
285
|
+
import Object from './platform/component/svg/Object'
|
|
285
286
|
import Path from './platform/component/svg/Path'
|
|
286
287
|
import Rect from './platform/component/svg/Rect'
|
|
287
288
|
import SVG from './platform/component/svg/SVG'
|
|
@@ -630,6 +631,7 @@ export default {
|
|
|
630
631
|
'be11165e-489f-11eb-921f-87b924eb0725': Group,
|
|
631
632
|
'38d26d76-2559-11eb-ae02-dfda9b9b137e': Line,
|
|
632
633
|
'9932f3bc-9241-11ea-89fa-0b2fdace0f08': Marker,
|
|
634
|
+
'c90ea697-ba4f-48ca-85e0-d9f26731e33e': Object,
|
|
633
635
|
'60bc7930-8982-11ea-8b24-cf97a783bb32': Path,
|
|
634
636
|
'c0bfe832-8967-11ea-8c4c-1f2995e41b68': Rect,
|
|
635
637
|
'98c279fc-7f5e-11ea-b9e4-f772f9f0bed1': SVG,
|
|
@@ -44,6 +44,7 @@ import ForeignObject from './platform/component/svg/ForeignObject/Component'
|
|
|
44
44
|
import Group from './platform/component/svg/Group/Component'
|
|
45
45
|
import Line from './platform/component/svg/Line/Component'
|
|
46
46
|
import Marker from './platform/component/svg/Marker/Component'
|
|
47
|
+
import Object from './platform/component/svg/Object/Component'
|
|
47
48
|
import Path from './platform/component/svg/Path/Component'
|
|
48
49
|
import Rect from './platform/component/svg/Rect/Component'
|
|
49
50
|
import SVG from './platform/component/svg/SVG/Component'
|
|
@@ -113,6 +114,7 @@ export default {
|
|
|
113
114
|
'be11165e-489f-11eb-921f-87b924eb0725': Group,
|
|
114
115
|
'38d26d76-2559-11eb-ae02-dfda9b9b137e': Line,
|
|
115
116
|
'9932f3bc-9241-11ea-89fa-0b2fdace0f08': Marker,
|
|
117
|
+
'c90ea697-ba4f-48ca-85e0-d9f26731e33e': Object,
|
|
116
118
|
'60bc7930-8982-11ea-8b24-cf97a783bb32': Path,
|
|
117
119
|
'c0bfe832-8967-11ea-8c4c-1f2995e41b68': Rect,
|
|
118
120
|
'98c279fc-7f5e-11ea-b9e4-f772f9f0bed1': SVG,
|
package/src/system/_ids.ts
CHANGED
|
@@ -492,6 +492,7 @@ export const ID_FOREIGN_OBJECT = 'e049f16e-2559-11eb-bdc4-db5b8a11164b'
|
|
|
492
492
|
export const ID_G = 'be11165e-489f-11eb-921f-87b924eb0725'
|
|
493
493
|
export const ID_LINE = '38d26d76-2559-11eb-ae02-dfda9b9b137e'
|
|
494
494
|
export const ID_MARKER = '9932f3bc-9241-11ea-89fa-0b2fdace0f08'
|
|
495
|
+
export const ID_SVG_OBJECT = 'c90ea697-ba4f-48ca-85e0-d9f26731e33e'
|
|
495
496
|
export const ID_PATH = '60bc7930-8982-11ea-8b24-cf97a783bb32'
|
|
496
497
|
export const ID_RECT = 'c0bfe832-8967-11ea-8c4c-1f2995e41b68'
|
|
497
498
|
export const ID_SVG = '98c279fc-7f5e-11ea-b9e4-f772f9f0bed1'
|