@floegence/floe-webapp-core 0.86.10 → 0.86.12
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/components/graph/layout.js +72 -71
- package/dist/components/graph/packing.js +35 -35
- package/dist/components/graph/positions.js +47 -46
- package/dist/components/graph/routing.d.ts +2 -2
- package/dist/components/graph/routing.js +188 -185
- package/dist/components/graph/types.d.ts +2 -0
- package/dist/remote-input.d.ts +2 -0
- package/dist/remote-input.js +86 -71
- package/dist/remote-pointer.js +135 -127
- package/package.json +1 -1
package/dist/remote-input.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
function
|
|
2
|
-
const { surface:
|
|
3
|
-
if (!
|
|
4
|
-
const t =
|
|
5
|
-
t.className = "floe-remote-input", t.setAttribute("aria-label",
|
|
6
|
-
let l = null,
|
|
7
|
-
const
|
|
8
|
-
let
|
|
9
|
-
const
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
e.addEventListener(i,
|
|
1
|
+
function W(n) {
|
|
2
|
+
const { surface: E } = n, K = E.ownerDocument, u = K.defaultView;
|
|
3
|
+
if (!u) throw new Error("Remote input requires an attached document");
|
|
4
|
+
const t = K.createElement("textarea");
|
|
5
|
+
t.className = "floe-remote-input", t.setAttribute("aria-label", n.label), t.setAttribute("autocorrect", "off"), t.autocomplete = "off", t.autocapitalize = "off", t.spellcheck = !1, t.wrap = "off", t.disabled = !0, t.tabIndex = -1, K.body.append(t);
|
|
6
|
+
let l = null, g = 0, c = !1, S = !1, o = null, m = !1, s = null, h = "physical";
|
|
7
|
+
const w = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Set(), M = /* @__PURE__ */ new Set();
|
|
8
|
+
let T = null;
|
|
9
|
+
const z = [];
|
|
10
|
+
function a(e, i, r) {
|
|
11
|
+
const k = r;
|
|
12
|
+
e.addEventListener(i, k), z.push(() => e.removeEventListener(i, k));
|
|
13
13
|
}
|
|
14
14
|
const b = (e) => e.code || e.key, x = (e, i) => ({
|
|
15
15
|
key: e.key,
|
|
@@ -22,71 +22,83 @@ function I(a) {
|
|
|
22
22
|
altKey: e.altKey,
|
|
23
23
|
metaKey: e.metaKey
|
|
24
24
|
});
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
function f() {
|
|
29
|
-
const e = M.getBoundingClientRect(), i = c.visualViewport, r = Math.max(e.left, i?.offsetLeft ?? 0), g = Math.max(e.top, i?.offsetTop ?? 0), D = Math.min(e.right, (i?.offsetLeft ?? 0) + (i?.width ?? c.innerWidth)), F = Math.min(e.bottom, (i?.offsetTop ?? 0) + (i?.height ?? c.innerHeight)), L = Math.max(1, Math.min(320, D - r - 8));
|
|
30
|
-
t.style.maxWidth = `${L}px`;
|
|
31
|
-
const S = t.getBoundingClientRect(), P = C?.x ?? r + 12, R = C?.y ?? g + 12;
|
|
32
|
-
t.style.left = `${Math.max(r, Math.min(P, D - S.width - 4))}px`, t.style.top = `${Math.max(g, Math.min(R, F - S.height - 4))}px`;
|
|
25
|
+
function C(e) {
|
|
26
|
+
S !== e && (S = e, n.onKeyboardVisibilityChange?.(e));
|
|
33
27
|
}
|
|
34
28
|
function d() {
|
|
29
|
+
const e = E.getBoundingClientRect(), i = u.visualViewport, r = Math.max(e.left, i?.offsetLeft ?? 0), k = Math.max(e.top, i?.offsetTop ?? 0), B = Math.min(e.right, (i?.offsetLeft ?? 0) + (i?.width ?? u.innerWidth)), P = Math.min(e.bottom, (i?.offsetTop ?? 0) + (i?.height ?? u.innerHeight)), R = Math.max(1, Math.min(320, B - r - 8));
|
|
30
|
+
t.style.maxWidth = `${R}px`;
|
|
31
|
+
const D = t.getBoundingClientRect(), $ = T?.x ?? r + 12, N = T?.y ?? k + 12;
|
|
32
|
+
t.style.left = `${Math.max(r, Math.min($, B - D.width - 4))}px`, t.style.top = `${Math.max(k, Math.min(N, P - D.height - 4))}px`;
|
|
33
|
+
}
|
|
34
|
+
function p() {
|
|
35
35
|
t.value = "", delete t.dataset.composing, s = null;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
const e = l, i =
|
|
39
|
-
|
|
37
|
+
function A() {
|
|
38
|
+
const e = l, i = f.size > 0;
|
|
39
|
+
f.clear(), w.clear(), e !== null && i && n.release(e);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
41
|
+
function y() {
|
|
42
|
+
g++, o && (o.cancelled = !0), m = !0, p(), A(), o && K.activeElement === t && t.blur();
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
!e || l === null ||
|
|
44
|
+
function V(e) {
|
|
45
|
+
!e || l === null || c || (h === "text" && f.size && (f.clear(), n.release(l)), n.commitText(e, l));
|
|
46
|
+
}
|
|
47
|
+
function L(e) {
|
|
48
|
+
if (l !== null) {
|
|
49
|
+
if (h === "text")
|
|
50
|
+
for (const [i, r] of w)
|
|
51
|
+
f.has(i) || (f.add(i), n.sendKey(r, l));
|
|
52
|
+
f.add(e.code || e.key), n.sendKey(e, l);
|
|
53
|
+
}
|
|
46
54
|
}
|
|
47
|
-
function
|
|
55
|
+
function F(e) {
|
|
48
56
|
if (l === null) return;
|
|
49
57
|
const i = { key: e, code: e, pressed: !0, repeat: !1, shiftKey: !1, ctrlKey: !1, altKey: !1, metaKey: !1, location: 0 }, r = l;
|
|
50
|
-
|
|
58
|
+
n.sendKey(i, r), l === r && n.sendKey({ ...i, pressed: !1 }, r);
|
|
51
59
|
}
|
|
52
|
-
function
|
|
53
|
-
if (l === null ||
|
|
54
|
-
|
|
60
|
+
function I(e) {
|
|
61
|
+
if (l === null || c) {
|
|
62
|
+
p();
|
|
55
63
|
return;
|
|
56
64
|
}
|
|
57
|
-
if (o?.cancelled || o && o.epoch !==
|
|
58
|
-
|
|
65
|
+
if (o?.cancelled || o && o.epoch !== g) {
|
|
66
|
+
p();
|
|
59
67
|
return;
|
|
60
68
|
}
|
|
61
69
|
if (e.isComposing) {
|
|
62
|
-
o ??= { epoch:
|
|
70
|
+
o ??= { epoch: g, committed: !1, cancelled: !1 }, t.dataset.composing = "true", d();
|
|
63
71
|
return;
|
|
64
72
|
}
|
|
65
73
|
if (o) {
|
|
66
|
-
!o.committed && t.value && (o.committed = !0,
|
|
74
|
+
!o.committed && t.value && (o.committed = !0, V(t.value)), p();
|
|
67
75
|
return;
|
|
68
76
|
}
|
|
69
|
-
if (
|
|
70
|
-
|
|
77
|
+
if (m || e.inputType === "insertFromComposition") {
|
|
78
|
+
m = !1, p();
|
|
71
79
|
return;
|
|
72
80
|
}
|
|
73
81
|
const i = t.value;
|
|
74
|
-
if (s && i === s.key && !s.altKey && i.length === 1) {
|
|
82
|
+
if (h === "physical" && s && i === s.key && !s.altKey && i.length === 1) {
|
|
75
83
|
const r = s;
|
|
76
|
-
|
|
77
|
-
} else
|
|
78
|
-
|
|
84
|
+
f.add(r.code || r.key), n.sendKey(r, l);
|
|
85
|
+
} else V(i);
|
|
86
|
+
p();
|
|
79
87
|
}
|
|
80
|
-
return
|
|
81
|
-
if (!(l === null ||
|
|
88
|
+
return a(t, "keydown", (e) => {
|
|
89
|
+
if (!(l === null || c)) {
|
|
82
90
|
if (e.stopPropagation(), o?.cancelled && !e.isComposing && e.key !== "Process" && e.keyCode !== 229 && (o = null), e.isComposing || o || e.key === "Process" || e.keyCode === 229) {
|
|
83
|
-
|
|
91
|
+
M.add(b(e)), s = null;
|
|
84
92
|
return;
|
|
85
93
|
}
|
|
86
|
-
if (
|
|
94
|
+
if (M.delete(b(e)), m = !1, n.clipboard?.(e, l)) {
|
|
87
95
|
s = null;
|
|
88
96
|
return;
|
|
89
97
|
}
|
|
98
|
+
if (h === "text" && /^(Shift|Control|Alt|Meta)(Left|Right)$/.test(e.code)) {
|
|
99
|
+
w.set(b(e), x(e, !0));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
90
102
|
if (e.key === "Dead" || e.key === "Unidentified") {
|
|
91
103
|
s = null;
|
|
92
104
|
return;
|
|
@@ -95,51 +107,54 @@ function I(a) {
|
|
|
95
107
|
s = x(e, !0);
|
|
96
108
|
return;
|
|
97
109
|
}
|
|
98
|
-
e.preventDefault(),
|
|
110
|
+
e.preventDefault(), L(x(e, !0));
|
|
99
111
|
}
|
|
100
|
-
}),
|
|
101
|
-
e.stopPropagation(), s = null,
|
|
102
|
-
}),
|
|
103
|
-
if (l === null ||
|
|
112
|
+
}), a(t, "keyup", (e) => {
|
|
113
|
+
e.stopPropagation(), s = null, w.delete(b(e)), !M.delete(b(e)) && l !== null && f.delete(b(e)) && n.sendKey(x(e, !1), l);
|
|
114
|
+
}), a(t, "beforeinput", (e) => {
|
|
115
|
+
if (l === null || c) {
|
|
104
116
|
e.preventDefault();
|
|
105
117
|
return;
|
|
106
118
|
}
|
|
107
119
|
if (e.isComposing || o || e.inputType === "insertCompositionText" || e.inputType === "deleteCompositionText" || e.inputType === "insertFromComposition") return;
|
|
108
|
-
|
|
120
|
+
m = !1;
|
|
109
121
|
const r = { deleteContentBackward: "Backspace", deleteContentForward: "Delete", insertLineBreak: "Enter", insertParagraph: "Enter" }[e.inputType];
|
|
110
|
-
r && (e.preventDefault(),
|
|
111
|
-
}),
|
|
112
|
-
o = { epoch:
|
|
113
|
-
}),
|
|
122
|
+
r && (e.preventDefault(), p(), F(r));
|
|
123
|
+
}), a(t, "input", I), a(t, "compositionstart", () => {
|
|
124
|
+
o = { epoch: g, committed: !1, cancelled: l === null }, m = !1, s = null, t.dataset.composing = "true", d();
|
|
125
|
+
}), a(t, "compositionend", (e) => {
|
|
114
126
|
const i = o;
|
|
115
|
-
o = null,
|
|
116
|
-
}),
|
|
117
|
-
|
|
118
|
-
}),
|
|
127
|
+
o = null, m = !0, p(), i && !i.cancelled && !i.committed && i.epoch === g && V(e.data);
|
|
128
|
+
}), a(t, "blur", () => {
|
|
129
|
+
y(), C(!1);
|
|
130
|
+
}), a(u, "blur", y), a(u, "pagehide", y), a(u, "resize", d), u.visualViewport && (a(u.visualViewport, "resize", d), a(u.visualViewport, "scroll", d)), d(), {
|
|
119
131
|
element: t,
|
|
120
132
|
bindTarget(e) {
|
|
121
|
-
|
|
133
|
+
c || Object.is(l, e) || (y(), l = e, t.disabled = e === null);
|
|
134
|
+
},
|
|
135
|
+
setTextInputMode(e) {
|
|
136
|
+
c || e === h || (y(), h = e);
|
|
122
137
|
},
|
|
123
138
|
setAnchor(e, i) {
|
|
124
|
-
!Number.isFinite(e) || !Number.isFinite(i) || (
|
|
139
|
+
!Number.isFinite(e) || !Number.isFinite(i) || (T = { x: e, y: i }, d());
|
|
125
140
|
},
|
|
126
141
|
focus() {
|
|
127
|
-
l === null ||
|
|
142
|
+
l === null || c || (t.focus({ preventScroll: !0 }), d());
|
|
128
143
|
},
|
|
129
144
|
setKeyboardVisible(e) {
|
|
130
|
-
e && l !== null && !
|
|
145
|
+
e && l !== null && !c ? (t.focus({ preventScroll: !0 }), C(!0), d()) : (t.blur(), C(!1));
|
|
131
146
|
},
|
|
132
|
-
release:
|
|
133
|
-
reset:
|
|
147
|
+
release: A,
|
|
148
|
+
reset: y,
|
|
134
149
|
dispose() {
|
|
135
|
-
if (!
|
|
136
|
-
|
|
137
|
-
for (const e of
|
|
138
|
-
t.remove(),
|
|
150
|
+
if (!c) {
|
|
151
|
+
y(), c = !0, l = null;
|
|
152
|
+
for (const e of z) e();
|
|
153
|
+
t.remove(), C(!1);
|
|
139
154
|
}
|
|
140
155
|
}
|
|
141
156
|
};
|
|
142
157
|
}
|
|
143
158
|
export {
|
|
144
|
-
|
|
159
|
+
W as createRemoteInput
|
|
145
160
|
};
|
package/dist/remote-pointer.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const W = 8.333333333333334;
|
|
2
|
+
function $(f) {
|
|
3
|
+
const { surface: c } = f, I = c.ownerDocument, r = I.defaultView;
|
|
4
|
+
if (!r) throw new Error("Remote pointer requires an attached document");
|
|
5
|
+
let o = null, d = null, u = null, p = null, w = 0, S = !1, M = 0, H = -1 / 0, b = 0, z = 0, A = !1, K = !1, E = 0, D = !1;
|
|
6
|
+
const g = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Map(), P = [], T = (e) => !K && f.isTargetValid(e), _ = (e, t) => Math.hypot(e.clientX - t.clientX, e.clientY - t.clientY), v = (e) => ({
|
|
6
7
|
clientX: e.clientX,
|
|
7
8
|
clientY: e.clientY,
|
|
8
9
|
shiftKey: e.shiftKey,
|
|
@@ -15,199 +16,206 @@ function R(d) {
|
|
|
15
16
|
const s = n;
|
|
16
17
|
e.addEventListener(t, s, { capture: i, passive: !1 }), P.push(() => e.removeEventListener(t, s, i));
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
-
const n =
|
|
20
|
-
if (n && e.kind === "move")
|
|
21
|
-
|
|
19
|
+
function B(e, t) {
|
|
20
|
+
const n = T(t) && f.sendPointer(e, t) !== !1;
|
|
21
|
+
if (n && e.kind === "move") {
|
|
22
|
+
H = r.performance.now();
|
|
23
|
+
for (const i of h.values()) i.target === t && (i.command = { ...i.command, ...v(e) });
|
|
24
|
+
}
|
|
22
25
|
return n;
|
|
23
26
|
}
|
|
24
27
|
function X() {
|
|
25
|
-
|
|
28
|
+
r.clearTimeout(z), z = 0, A && (A = !1, f.onHoldChange?.(null));
|
|
26
29
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
30
|
+
function V(e) {
|
|
31
|
+
x.delete(e), c.hasPointerCapture?.(e) && c.releasePointerCapture(e);
|
|
29
32
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
33
|
+
function F(e) {
|
|
34
|
+
c.setPointerCapture?.(e), x.add(e);
|
|
32
35
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
const e =
|
|
36
|
-
|
|
36
|
+
function m() {
|
|
37
|
+
b++, S = !1, w && r.cancelAnimationFrame(w), w = 0, r.clearTimeout(M), M = 0;
|
|
38
|
+
const e = d;
|
|
39
|
+
d = null, e && !B(e.command, e.target) && l();
|
|
37
40
|
}
|
|
38
41
|
function C(e, t) {
|
|
39
|
-
if (
|
|
40
|
-
if (e.kind === "scroll" &&
|
|
41
|
-
if (!
|
|
42
|
-
|
|
43
|
-
const n =
|
|
44
|
-
|
|
45
|
-
n
|
|
42
|
+
if (d && (d.target !== t || d.command.kind !== e.kind) && m(), !!T(t)) {
|
|
43
|
+
if (e.kind === "scroll" && d?.command.kind === "scroll" && (e = { ...e, dx: d.command.dx + e.dx, dy: d.command.dy + e.dy }), d = { target: t, command: e }, e.kind === "move") {
|
|
44
|
+
if (!S && !M) {
|
|
45
|
+
S = !0;
|
|
46
|
+
const n = b;
|
|
47
|
+
r.queueMicrotask(() => {
|
|
48
|
+
if (n !== b) return;
|
|
49
|
+
S = !1;
|
|
50
|
+
const i = W - (r.performance.now() - H);
|
|
51
|
+
i <= 0 ? m() : M = r.setTimeout(() => {
|
|
52
|
+
n === b && m();
|
|
53
|
+
}, Math.ceil(i));
|
|
46
54
|
});
|
|
47
55
|
}
|
|
48
56
|
return;
|
|
49
57
|
}
|
|
50
|
-
if (!
|
|
51
|
-
const n =
|
|
52
|
-
n ===
|
|
58
|
+
if (!w) {
|
|
59
|
+
const n = E, i = r.requestAnimationFrame(() => {
|
|
60
|
+
n === E && w === i && m();
|
|
53
61
|
});
|
|
54
|
-
|
|
62
|
+
w = i;
|
|
55
63
|
}
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
|
-
function
|
|
59
|
-
const
|
|
60
|
-
if (!e && !
|
|
61
|
-
e ||
|
|
62
|
-
const
|
|
63
|
-
|
|
66
|
+
function k(e, t, n, i, s = 1) {
|
|
67
|
+
const y = h.get(i);
|
|
68
|
+
if (!e && !y) return;
|
|
69
|
+
e || h.delete(i);
|
|
70
|
+
const O = { ...t, kind: e ? "down" : "up", button: i, clicks: s };
|
|
71
|
+
B(O, n) && e && h.set(i, { target: n, command: O });
|
|
64
72
|
}
|
|
65
73
|
function Y(e, t) {
|
|
66
|
-
const n =
|
|
67
|
-
return
|
|
74
|
+
const n = E;
|
|
75
|
+
return f.onActivate?.(e, t), n === E && T(t);
|
|
68
76
|
}
|
|
69
|
-
function
|
|
70
|
-
Y(e, t) && (
|
|
77
|
+
function N(e, t, n, i = 1) {
|
|
78
|
+
Y(e, t) && (k(!0, e, t, n, i), k(!1, e, t, n, i));
|
|
71
79
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
80
|
+
function l() {
|
|
81
|
+
E++, b++, S = !1, X(), w && r.cancelAnimationFrame(w), w = 0, r.clearTimeout(M), M = 0, H = -1 / 0;
|
|
74
82
|
const e = /* @__PURE__ */ new Set();
|
|
75
|
-
o && e.add(o.target),
|
|
76
|
-
for (const [t, n] of
|
|
77
|
-
e.add(n.target),
|
|
78
|
-
for (const t of e)
|
|
79
|
-
for (const t of [...
|
|
83
|
+
o && e.add(o.target), d && e.add(d.target), u !== null && e.add(u), d = null, o = null, u = null, p = null, D = g.size > 0;
|
|
84
|
+
for (const [t, n] of h)
|
|
85
|
+
e.add(n.target), k(!1, n.command, n.target, t);
|
|
86
|
+
for (const t of e) f.release(t);
|
|
87
|
+
for (const t of [...x]) V(t);
|
|
80
88
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
89
|
+
function L(e) {
|
|
90
|
+
g.delete(e), V(e), g.size || (D = !1);
|
|
83
91
|
}
|
|
84
|
-
function
|
|
92
|
+
function R(e) {
|
|
85
93
|
const t = o;
|
|
86
94
|
if (!t || t.id !== e.pointerId) return;
|
|
87
|
-
if (!
|
|
88
|
-
|
|
95
|
+
if (!T(t.target)) {
|
|
96
|
+
l();
|
|
89
97
|
return;
|
|
90
98
|
}
|
|
91
|
-
const n =
|
|
92
|
-
if ((t.mode === "pending" || t.mode === "hold") &&
|
|
99
|
+
const n = v(e);
|
|
100
|
+
if ((t.mode === "pending" || t.mode === "hold") && _(t.origin, n) > 8) {
|
|
93
101
|
const i = t.mode === "hold";
|
|
94
|
-
if (X(), p = null, t.mode = i ? "drag" : "scroll", i && Y(t.origin, t.target) &&
|
|
102
|
+
if (X(), p = null, t.mode = i ? "drag" : "scroll", i && Y(t.origin, t.target) && k(!0, t.origin, t.target, 0), o !== t) return;
|
|
95
103
|
}
|
|
96
104
|
if (t.mode === "scroll") {
|
|
97
|
-
const i = t.last, s = i.clientX - n.clientX,
|
|
98
|
-
(s ||
|
|
105
|
+
const i = t.last, s = i.clientX - n.clientX, y = i.clientY - n.clientY;
|
|
106
|
+
(s || y) && C({ ...t.origin, kind: "scroll", dx: s, dy: y }, t.target), t.last = n;
|
|
99
107
|
} else t.mode === "drag" && (C({ ...n, kind: "move" }, t.target), t.last = n);
|
|
100
108
|
}
|
|
101
|
-
a(
|
|
102
|
-
const t =
|
|
103
|
-
if (t === null || !
|
|
104
|
-
const n =
|
|
109
|
+
a(c, "pointerdown", (e) => {
|
|
110
|
+
const t = f.resolveTarget(e);
|
|
111
|
+
if (t === null || !T(t)) return;
|
|
112
|
+
const n = v(e);
|
|
105
113
|
if (e.pointerType === "touch") {
|
|
106
|
-
if (
|
|
107
|
-
|
|
114
|
+
if (g.add(e.pointerId), g.size > 1 || D) {
|
|
115
|
+
l();
|
|
108
116
|
return;
|
|
109
117
|
}
|
|
110
|
-
(o ||
|
|
118
|
+
(o || h.size) && l(), m(), u !== null && (f.release(u), u = null), D = !1, o = { id: e.pointerId, target: t, origin: n, last: n, mode: "pending" };
|
|
111
119
|
const i = o;
|
|
112
|
-
|
|
113
|
-
if (
|
|
114
|
-
if (!
|
|
115
|
-
|
|
120
|
+
z = r.setTimeout(() => {
|
|
121
|
+
if (z = 0, o === i) {
|
|
122
|
+
if (!T(t)) {
|
|
123
|
+
l();
|
|
116
124
|
return;
|
|
117
125
|
}
|
|
118
|
-
i.mode = "hold",
|
|
126
|
+
i.mode = "hold", A = !0, f.onHoldChange?.({ ...n, target: t });
|
|
119
127
|
}
|
|
120
128
|
}, 450);
|
|
121
129
|
} else {
|
|
122
|
-
if (
|
|
123
|
-
|
|
130
|
+
if (g.size) {
|
|
131
|
+
l();
|
|
124
132
|
return;
|
|
125
133
|
}
|
|
126
|
-
o && (o.id !== e.pointerId || o.target !== t) &&
|
|
127
|
-
const i = e.button === 0 && p?.target === t &&
|
|
128
|
-
Y(n, t) &&
|
|
134
|
+
o && (o.id !== e.pointerId || o.target !== t) && l(), m(), u !== null && (f.release(u), u = null), o = { id: e.pointerId, target: t, origin: n, last: n, mode: "direct" };
|
|
135
|
+
const i = e.button === 0 && p?.target === t && r.performance.now() - p.time <= 350 && _(p.position, n) <= 16;
|
|
136
|
+
Y(n, t) && k(!0, n, t, e.button, Math.max(1, e.detail, i ? 2 : 1));
|
|
129
137
|
}
|
|
130
|
-
|
|
138
|
+
F(e.pointerId), e.pointerType === "touch" && e.preventDefault();
|
|
131
139
|
});
|
|
132
|
-
const
|
|
133
|
-
function
|
|
134
|
-
if (D ||
|
|
135
|
-
const n = o?.target ??
|
|
136
|
-
if (n === null || !
|
|
137
|
-
o &&
|
|
140
|
+
const U = "onpointerrawupdate" in r;
|
|
141
|
+
function q(e, t) {
|
|
142
|
+
if (D || g.size) return;
|
|
143
|
+
const n = o?.target ?? f.resolveTarget(e);
|
|
144
|
+
if (n === null || !T(n)) {
|
|
145
|
+
o && l();
|
|
138
146
|
return;
|
|
139
147
|
}
|
|
140
|
-
const i =
|
|
148
|
+
const i = v(e);
|
|
141
149
|
if (o) {
|
|
142
150
|
t && (o.last = i);
|
|
143
|
-
for (const [s,
|
|
144
|
-
const
|
|
145
|
-
|
|
151
|
+
for (const [s, y] of [[0, 1], [1, 4], [2, 2], [3, 8], [4, 16]]) {
|
|
152
|
+
const O = !!(e.buttons & y);
|
|
153
|
+
O !== h.has(s) && (m(), k(O, i, n, s));
|
|
146
154
|
}
|
|
147
155
|
}
|
|
148
156
|
t && C({ ...i, kind: "move" }, n);
|
|
149
157
|
}
|
|
150
|
-
|
|
151
|
-
e.pointerType !== "touch" &&
|
|
152
|
-
}), a(
|
|
153
|
-
e.pointerType === "touch" ?
|
|
154
|
-
}), a(
|
|
158
|
+
U && a(c, "pointerrawupdate", (e) => {
|
|
159
|
+
e.pointerType !== "touch" && q(e, !0);
|
|
160
|
+
}), a(c, "pointermove", (e) => {
|
|
161
|
+
e.pointerType === "touch" ? R(e) : q(e, !U);
|
|
162
|
+
}), a(c, "pointerup", (e) => {
|
|
155
163
|
const t = o;
|
|
156
164
|
if (t?.id === e.pointerId && !D)
|
|
157
|
-
if (!
|
|
165
|
+
if (!T(t.target)) l();
|
|
158
166
|
else if (e.pointerType === "touch") {
|
|
159
|
-
|
|
160
|
-
const n =
|
|
167
|
+
R(e), X();
|
|
168
|
+
const n = v(e);
|
|
161
169
|
if (t.mode === "pending") {
|
|
162
|
-
const i =
|
|
163
|
-
|
|
164
|
-
} else t.mode === "hold" ? (p = null,
|
|
165
|
-
|
|
170
|
+
const i = r.performance.now(), s = p?.target === t.target && i - p.time <= 350 && _(p.position, n) <= 16;
|
|
171
|
+
N(n, t.target, 0, s ? 2 : 1), p = s ? null : { target: t.target, position: n, time: i };
|
|
172
|
+
} else t.mode === "hold" ? (p = null, N(n, t.target, 2)) : (m(), t.mode === "drag" && k(!1, n, t.target, 0));
|
|
173
|
+
f.release(t.target), o = null;
|
|
166
174
|
} else {
|
|
167
|
-
|
|
168
|
-
const n =
|
|
169
|
-
for (const i of [...
|
|
170
|
-
p = e.button === 0 && n && "clicks" in n && n.clicks === 1 &&
|
|
175
|
+
d?.command.kind === "move" && (d.command = { ...v(e), kind: "move" }), m();
|
|
176
|
+
const n = h.get(e.button)?.command;
|
|
177
|
+
for (const i of [...h.keys()]) k(!1, v(e), t.target, i, n && "clicks" in n ? n.clicks : 1);
|
|
178
|
+
p = e.button === 0 && n && "clicks" in n && n.clicks === 1 && _(t.origin, v(e)) <= 8 ? { target: t.target, position: v(e), time: r.performance.now() } : null, h.size || (o = null);
|
|
171
179
|
}
|
|
172
|
-
(!o || o.id !== e.pointerId) &&
|
|
173
|
-
}), a(
|
|
174
|
-
|
|
175
|
-
}), a(
|
|
176
|
-
|
|
180
|
+
(!o || o.id !== e.pointerId) && L(e.pointerId);
|
|
181
|
+
}), a(c, "pointercancel", (e) => {
|
|
182
|
+
l(), L(e.pointerId);
|
|
183
|
+
}), a(c, "lostpointercapture", (e) => {
|
|
184
|
+
x.has(e.pointerId) && (l(), L(e.pointerId));
|
|
177
185
|
}), a(I, "pointerup", (e) => {
|
|
178
|
-
o?.id !== e.pointerId &&
|
|
179
|
-
}), a(I, "pointercancel", (e) =>
|
|
180
|
-
o && (e.pointerType === "touch" && e.pointerId !== o.id ? (
|
|
181
|
-
}, !0), a(
|
|
182
|
-
const t =
|
|
183
|
-
if (t === null || !
|
|
184
|
-
p = null, u !== null && u !== t && (
|
|
185
|
-
const n = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ?
|
|
186
|
-
Number.isFinite(s) && Number.isFinite(
|
|
186
|
+
o?.id !== e.pointerId && L(e.pointerId);
|
|
187
|
+
}), a(I, "pointercancel", (e) => L(e.pointerId)), a(I, "pointerdown", (e) => {
|
|
188
|
+
o && (e.pointerType === "touch" && e.pointerId !== o.id ? (g.add(e.pointerId), l()) : c.contains(e.target) || l());
|
|
189
|
+
}, !0), a(c, "wheel", (e) => {
|
|
190
|
+
const t = f.resolveTarget(e);
|
|
191
|
+
if (t === null || !T(t) || (e.preventDefault(), o || g.size)) return;
|
|
192
|
+
p = null, u !== null && u !== t && (m(), f.release(u)), u = t;
|
|
193
|
+
const n = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? c.clientWidth || r.innerWidth : 1, i = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? c.clientHeight || r.innerHeight : 1, s = e.deltaX * n, y = e.deltaY * i;
|
|
194
|
+
Number.isFinite(s) && Number.isFinite(y) && (s || y) && C({ ...v(e), kind: "scroll", dx: s, dy: y }, t);
|
|
187
195
|
});
|
|
188
196
|
for (const e of ["mousedown", "mouseup", "click", "dblclick", "contextmenu", "dragstart", "selectstart"])
|
|
189
|
-
a(
|
|
190
|
-
|
|
197
|
+
a(c, e, (t) => {
|
|
198
|
+
f.resolveTarget(t) !== null && t.preventDefault();
|
|
191
199
|
});
|
|
192
|
-
for (const e of ["blur", "pagehide", "resize", "orientationchange"]) a(
|
|
200
|
+
for (const e of ["blur", "pagehide", "resize", "orientationchange"]) a(r, e, l);
|
|
193
201
|
if (a(I, "visibilitychange", () => {
|
|
194
|
-
I.hidden &&
|
|
195
|
-
}), a(
|
|
196
|
-
let e = `${
|
|
202
|
+
I.hidden && l();
|
|
203
|
+
}), a(r, "scroll", l, !0), r.visualViewport && (a(r.visualViewport, "resize", l), a(r.visualViewport, "scroll", l)), typeof ResizeObserver < "u") {
|
|
204
|
+
let e = `${c.clientWidth}:${c.clientHeight}`;
|
|
197
205
|
const t = new ResizeObserver(() => {
|
|
198
|
-
const n = `${
|
|
199
|
-
n !== e && (e = n,
|
|
206
|
+
const n = `${c.clientWidth}:${c.clientHeight}`;
|
|
207
|
+
n !== e && (e = n, l());
|
|
200
208
|
});
|
|
201
|
-
t.observe(
|
|
209
|
+
t.observe(c), P.push(() => t.disconnect());
|
|
202
210
|
}
|
|
203
|
-
return { flush:
|
|
211
|
+
return { flush: m, reset: l, dispose() {
|
|
204
212
|
if (!K) {
|
|
205
|
-
|
|
213
|
+
l(), K = !0;
|
|
206
214
|
for (const e of P) e();
|
|
207
|
-
|
|
215
|
+
g.clear();
|
|
208
216
|
}
|
|
209
217
|
} };
|
|
210
218
|
}
|
|
211
219
|
export {
|
|
212
|
-
|
|
220
|
+
$ as createRemotePointer
|
|
213
221
|
};
|