@floegence/floe-webapp-core 0.86.8 → 0.86.11

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.
@@ -1,202 +1,274 @@
1
- import { AvoidLib as H } from "../../node_modules/.pnpm/libavoid-js@0.5.0-beta.5/node_modules/libavoid-js/dist/index.js";
2
- import W from "../../node_modules/.pnpm/libavoid-js@0.5.0-beta.5/node_modules/libavoid-js/dist/libavoid.wasm.js";
3
- let N;
4
- const B = { NORTH: 1, SOUTH: 2, WEST: 4, EAST: 8 }, v = ["NORTH", "EAST", "SOUTH", "WEST"], m = (t) => t.delete();
5
- async function F(t) {
6
- if (!t.nodes.length) return t;
7
- if (!t.edges.length) return C(t);
8
- await (N ??= H.load(W).catch((h) => {
9
- throw N = void 0, h;
1
+ import { AvoidLib as G } from "../../node_modules/.pnpm/libavoid-js@0.5.0-beta.5/node_modules/libavoid-js/dist/index.js";
2
+ import V from "../../node_modules/.pnpm/libavoid-js@0.5.0-beta.5/node_modules/libavoid-js/dist/libavoid.wasm.js";
3
+ let J;
4
+ const j = { NORTH: 1, SOUTH: 2, WEST: 4, EAST: 8 }, N = ["NORTH", "EAST", "SOUTH", "WEST"], O = (n) => n.delete();
5
+ async function $(n) {
6
+ if (!n.nodes.length) return n;
7
+ if (!n.edges.length) return F(n);
8
+ await (J ??= G.load(V).catch((y) => {
9
+ throw J = void 0, y;
10
10
  }));
11
- const e = H.getInstance(), s = new Map(t.nodes.map((h) => [h.id, h])), d = (h) => {
12
- const y = [];
13
- for (let r = s.get(h).parentId; r; r = s.get(r).parentId)
14
- y.push(r);
15
- return y;
16
- }, i = /* @__PURE__ */ new Map();
17
- for (const h of t.edges) {
18
- const y = /* @__PURE__ */ new Set([...d(h.source), ...d(h.target)]), r = JSON.stringify([...y].sort()), S = i.get(r) ?? { open: y, edges: [] };
19
- S.edges.push(h), i.set(r, S);
11
+ const s = G.getInstance(), r = new Map(n.nodes.map((y) => [y.id, y])), p = (y) => {
12
+ const m = [];
13
+ for (let i = r.get(y).parentId; i; i = r.get(i).parentId)
14
+ m.push(i);
15
+ return m;
16
+ }, x = /* @__PURE__ */ new Map();
17
+ for (const y of n.edges) {
18
+ const m = /* @__PURE__ */ new Set([...p(y.source), ...p(y.target)]), i = JSON.stringify([...m].sort()), e = x.get(i) ?? { open: m, edges: [] };
19
+ e.edges.push(y), x.set(i, e);
20
20
  }
21
- const f = /* @__PURE__ */ new Map();
22
- for (const { open: h, edges: y } of i.values()) {
23
- const r = new e.Router(2);
21
+ const T = /* @__PURE__ */ new Map();
22
+ for (const { open: y, edges: m } of x.values()) {
23
+ const i = new s.Router(2);
24
24
  try {
25
- r.setRoutingParameter(e.RoutingParameter.shapeBufferDistance, 4), r.setRoutingParameter(e.RoutingParameter.idealNudgingDistance, 8), r.setRoutingParameter(e.RoutingParameter.crossingPenalty, 80), r.setRoutingParameter(e.RoutingParameter.fixedSharedPathPenalty, 120), r.setRoutingParameter(e.RoutingParameter.portDirectionPenalty, 0), r.setRoutingOption(e.RoutingOption.nudgeOrthogonalSegmentsConnectedToShapes, !1), r.setRoutingOption(e.RoutingOption.nudgeSharedPathsWithCommonEndPoint, !0);
26
- const S = new Map(
27
- t.nodes.filter((n) => !h.has(n.id) && d(n.id).every((a) => h.has(a))).map((n) => {
28
- const a = new e.Point(n.x, n.y), p = new e.Point(n.x + n.width, n.y + n.height), o = new e.Rectangle(a, p), c = new e.ShapeRef(r, o);
29
- return m(a), m(p), m(o), [n.id, c];
25
+ i.setRoutingParameter(s.RoutingParameter.shapeBufferDistance, 4), i.setRoutingParameter(s.RoutingParameter.idealNudgingDistance, 8), i.setRoutingParameter(s.RoutingParameter.crossingPenalty, 80), i.setRoutingParameter(s.RoutingParameter.fixedSharedPathPenalty, 120), i.setRoutingParameter(s.RoutingParameter.portDirectionPenalty, 0), i.setRoutingOption(s.RoutingOption.nudgeOrthogonalSegmentsConnectedToShapes, !1), i.setRoutingOption(s.RoutingOption.nudgeSharedPathsWithCommonEndPoint, !0);
26
+ const e = new Map(
27
+ n.nodes.filter((t) => !y.has(t.id) && p(t.id).every((o) => y.has(o))).map((t) => {
28
+ const o = new s.Point(t.x, t.y), g = new s.Point(t.x + t.width, t.y + t.height), a = new s.Rectangle(o, g), h = new s.ShapeRef(i, a);
29
+ return O(o), O(g), O(a), [t.id, h];
30
30
  })
31
- ), P = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map();
32
- y.forEach((n) => {
33
- const a = s.get(n.source), p = s.get(n.target), o = D(a, p), c = n.sourcePort ? a.ports.find((u) => u.id === n.sourcePort).side : n.targetPort ? O(p.ports.find((u) => u.id === n.targetPort).side) : o.source, g = n.targetPort ? p.ports.find((u) => u.id === n.targetPort).side : n.sourcePort ? O(a.ports.find((u) => u.id === n.sourcePort).side) : o.target, w = [n.source, n.target].sort().join("\0"), x = R.get(w) ?? 0;
34
- R.set(w, x + 1), P.set(n.id, {
35
- sourceSide: c,
36
- targetSide: g,
37
- offset: x % 2 === 0 ? -6 : 6
31
+ ), c = /* @__PURE__ */ new Map(), S = n.nodes.filter((t) => e.has(t.id)), E = /* @__PURE__ */ new Map();
32
+ m.forEach((t) => {
33
+ const o = r.get(t.source), g = r.get(t.target), a = Y(o, g), h = t.sourcePort ? o.ports.find((P) => P.id === t.sourcePort).side : t.targetPort ? B(g.ports.find((P) => P.id === t.targetPort).side) : a.source, u = t.targetPort ? g.ports.find((P) => P.id === t.targetPort).side : t.sourcePort ? B(o.ports.find((P) => P.id === t.sourcePort).side) : a.target, d = [t.source, t.target].sort().join("\0"), f = E.get(d) ?? 0;
34
+ E.set(d, f + 1);
35
+ const M = f % 2 === 0 ? -6 : 6, R = t.source === t.target ? void 0 : X(
36
+ o,
37
+ g,
38
+ S,
39
+ a,
40
+ M,
41
+ t.sourcePort ? h : void 0,
42
+ t.targetPort ? u : void 0
43
+ );
44
+ c.set(t.id, {
45
+ sourceSide: R?.source ?? h,
46
+ targetSide: R?.target ?? u,
47
+ offset: M
38
48
  });
39
49
  });
40
- for (const n of t.nodes) {
41
- const a = S.get(n.id);
42
- if (!a) continue;
43
- const p = (o, c, g, w, x) => {
44
- const u = new e.ShapeConnectionPin(
45
- a,
50
+ let l = N.length + 2;
51
+ const A = /* @__PURE__ */ new Map(), C = (t, o) => Math.max(0, Math.min(1, t / o));
52
+ for (const t of n.nodes) {
53
+ const o = e.get(t.id);
54
+ if (!o) continue;
55
+ const g = (a, h, u, d, f) => {
56
+ const M = new s.ShapeConnectionPin(
46
57
  o,
47
- c / n.width,
48
- g / n.height,
58
+ a,
59
+ C(h, t.width),
60
+ C(u, t.height),
49
61
  !0,
50
62
  0,
51
- w
63
+ d
52
64
  );
53
- u.setExclusive(x), u.setConnectionCost(
54
- n.width / 2 + n.height / 2 - Math.abs(c - n.width / 2) - Math.abs(g - n.height / 2)
65
+ M.setExclusive(f), M.setConnectionCost(
66
+ t.width / 2 + t.height / 2 - Math.abs(h - t.width / 2) - Math.abs(u - t.height / 2)
55
67
  );
56
68
  };
57
- for (const o of new Set(n.ports?.map((c) => c.side))) {
58
- const { x: c, y: g } = A(n, o);
59
- p(v.indexOf(o) + 2, c - n.x, g - n.y, B[o], !1);
69
+ for (const a of new Set(t.ports?.map((h) => h.side))) {
70
+ const { x: h, y: u } = U(t, a), d = N.indexOf(a) + 2;
71
+ g(d, h - t.x, u - t.y, j[a], !1), A.set(
72
+ JSON.stringify([
73
+ t.id,
74
+ C(h - t.x, t.width),
75
+ C(u - t.y, t.height),
76
+ a
77
+ ]),
78
+ d
79
+ );
60
80
  }
61
81
  }
62
- const l = (n, a, p) => {
63
- const o = s.get(n), c = S.get(n);
64
- if (c && a)
65
- return new e.ConnEnd(
66
- c,
67
- v.indexOf(o.ports.find((u) => u.id === a).side) + 2
82
+ const H = (t, o, g, a) => {
83
+ const h = r.get(t), u = e.get(t);
84
+ if (u && o)
85
+ return new s.ConnEnd(
86
+ u,
87
+ N.indexOf(h.ports.find((R) => R.id === o).side) + 2
68
88
  );
69
- const g = a ? A(o, o.ports.find((u) => u.id === a).side) : p, w = new e.Point(g.x, g.y), x = new e.ConnEnd(w);
70
- return m(w), x;
71
- }, M = y.map((n) => {
72
- const a = s.get(n.source), p = s.get(n.target), o = P.get(n.id), c = l(
73
- n.source,
74
- n.sourcePort,
75
- n.source === n.target ? { x: a.x + a.width, y: a.y + a.height / 3 } : k(a, o.sourceSide, p, o.offset)
76
- ), g = l(
77
- n.target,
78
- n.targetPort,
79
- n.source === n.target ? {
80
- x: p.x + p.width,
81
- y: p.y + p.height * 2 / 3
82
- } : k(p, o.targetSide, a, o.offset)
83
- ), w = new e.ConnRef(r, c, g);
84
- if (m(c), m(g), n.source === n.target) {
85
- const x = s.get(n.source), u = new e.CheckpointVector();
86
- for (const U of [x.y + x.height / 3, x.y + x.height * 2 / 3]) {
87
- const E = new e.Point(x.x + x.width + 24, U), b = new e.Checkpoint(E);
88
- u.push_back(b), m(E), m(b);
89
+ if (u) {
90
+ const R = C(g.x - h.x, h.width), P = C(g.y - h.y, h.height), b = JSON.stringify([t, R, P, a]), D = A.get(b);
91
+ if (D !== void 0) return new s.ConnEnd(u, D);
92
+ const k = l++;
93
+ return A.set(b, k), new s.ShapeConnectionPin(
94
+ u,
95
+ k,
96
+ R,
97
+ P,
98
+ !0,
99
+ 0,
100
+ j[a]
101
+ ).setExclusive(!1), new s.ConnEnd(u, k);
102
+ }
103
+ const d = o ? U(h, h.ports.find((R) => R.id === o).side) : g, f = new s.Point(d.x, d.y), M = new s.ConnEnd(f);
104
+ return O(f), M;
105
+ }, v = m.map((t) => {
106
+ const o = r.get(t.source), g = r.get(t.target), a = c.get(t.id), h = H(
107
+ t.source,
108
+ t.sourcePort,
109
+ t.source === t.target ? { x: o.x + o.width, y: o.y + o.height / 3 } : W(o, a.sourceSide, g, a.offset),
110
+ t.source === t.target ? "EAST" : a.sourceSide
111
+ ), u = H(
112
+ t.target,
113
+ t.targetPort,
114
+ t.source === t.target ? {
115
+ x: g.x + g.width,
116
+ y: g.y + g.height * 2 / 3
117
+ } : W(g, a.targetSide, o, a.offset),
118
+ t.source === t.target ? "EAST" : a.targetSide
119
+ ), d = new s.ConnRef(i, h, u);
120
+ if (O(h), O(u), t.source === t.target) {
121
+ const f = r.get(t.source), M = new s.CheckpointVector();
122
+ for (const R of [f.y + f.height / 3, f.y + f.height * 2 / 3]) {
123
+ const P = new s.Point(f.x + f.width + 24, R), b = new s.Checkpoint(P);
124
+ M.push_back(b), O(P), O(b);
89
125
  }
90
- w.setRoutingCheckpoints(u), m(u);
126
+ d.setRoutingCheckpoints(M), O(M);
91
127
  }
92
- return { edge: n, connection: w };
128
+ return { edge: t, connection: d };
93
129
  });
94
- r.processTransaction();
95
- for (const { edge: n, connection: a } of M) {
96
- const p = a.displayRoute(), o = Array.from({ length: p.size() }, (c, g) => {
97
- const w = p.at(g), x = { x: w.x, y: w.y };
98
- return m(w), x;
130
+ i.processTransaction();
131
+ for (const { edge: t, connection: o } of v) {
132
+ const g = o.displayRoute(), a = Array.from({ length: g.size() }, (h, u) => {
133
+ const d = g.at(u), f = { x: d.x, y: d.y };
134
+ return O(d), f;
99
135
  });
100
- if (m(p), !a.hasValidRoute() || o.length < 2 || o.some((c) => !Number.isFinite(c.x) || !Number.isFinite(c.y)) || o.some((c, g) => g > 0 && c.x !== o[g - 1].x && c.y !== o[g - 1].y))
101
- throw new Error(`Graph edge cannot be routed: ${n.id}`);
102
- f.set(n.id, o);
136
+ if (O(g), !o.hasValidRoute() || a.length < 2 || a.some((h) => !Number.isFinite(h.x) || !Number.isFinite(h.y)) || a.some((h, u) => u > 0 && h.x !== a[u - 1].x && h.y !== a[u - 1].y))
137
+ throw new Error(`Graph edge cannot be routed: ${t.id}`);
138
+ T.set(t.id, a);
103
139
  }
104
140
  } finally {
105
- r.delete();
141
+ i.delete();
106
142
  }
107
143
  }
108
- const T = t.edges.map((h) => ({ ...h, sections: [f.get(h.id)] }));
109
- return C({
110
- nodes: t.nodes,
111
- edges: T,
112
- bounds: t.bounds
144
+ const w = n.edges.map((y) => ({ ...y, sections: [T.get(y.id)] }));
145
+ return F({
146
+ nodes: n.nodes,
147
+ edges: w,
148
+ bounds: n.bounds
113
149
  });
114
150
  }
115
- function C(t) {
116
- const e = [
117
- ...t.nodes.flatMap((i) => [
118
- { x: i.x, y: i.y },
119
- { x: i.x + i.width, y: i.y + i.height }
151
+ function F(n) {
152
+ const s = [
153
+ ...n.nodes.flatMap((x) => [
154
+ { x: x.x, y: x.y },
155
+ { x: x.x + x.width, y: x.y + x.height }
120
156
  ]),
121
- ...t.edges.flatMap((i) => i.sections.flat())
122
- ], s = Math.min(...e.map((i) => i.x)), d = Math.min(...e.map((i) => i.y));
157
+ ...n.edges.flatMap((x) => x.sections.flat())
158
+ ], r = Math.min(...s.map((x) => x.x)), p = Math.min(...s.map((x) => x.y));
123
159
  return {
124
- nodes: t.nodes,
125
- edges: t.edges,
160
+ nodes: n.nodes,
161
+ edges: n.edges,
126
162
  bounds: {
127
- x: s,
128
- y: d,
129
- width: Math.max(...e.map((i) => i.x)) - s,
130
- height: Math.max(...e.map((i) => i.y)) - d
163
+ x: r,
164
+ y: p,
165
+ width: Math.max(...s.map((x) => x.x)) - r,
166
+ height: Math.max(...s.map((x) => x.y)) - p
131
167
  }
132
168
  };
133
169
  }
134
- function A(t, e) {
170
+ function U(n, s) {
135
171
  return {
136
- x: e === "WEST" ? t.x : e === "EAST" ? t.x + t.width : t.x + t.width / 2,
137
- y: e === "NORTH" ? t.y : e === "SOUTH" ? t.y + t.height : t.y + t.height / 2
172
+ x: s === "WEST" ? n.x : s === "EAST" ? n.x + n.width : n.x + n.width / 2,
173
+ y: s === "NORTH" ? n.y : s === "SOUTH" ? n.y + n.height : n.y + n.height / 2
138
174
  };
139
175
  }
140
- function O(t) {
176
+ function B(n) {
141
177
  return {
142
178
  NORTH: "SOUTH",
143
179
  EAST: "WEST",
144
180
  SOUTH: "NORTH",
145
181
  WEST: "EAST"
146
- }[t];
182
+ }[n];
147
183
  }
148
- function D(t, e) {
149
- const s = e.x + e.width / 2 - (t.x + t.width / 2), d = e.y + e.height / 2 - (t.y + t.height / 2), i = Math.max(t.x - (e.x + e.width), e.x - (t.x + t.width), 0), f = Math.max(
150
- t.y - (e.y + e.height),
151
- e.y - (t.y + t.height),
184
+ function X(n, s, r, p, x, T, w) {
185
+ let y;
186
+ const m = (i, e, c) => c === "NORTH" ? e.x === i.x && e.y < i.y : c === "SOUTH" ? e.x === i.x && e.y > i.y : c === "WEST" ? e.y === i.y && e.x < i.x : e.y === i.y && e.x > i.x;
187
+ for (const i of T ? [T] : N)
188
+ for (const e of w ? [w] : N) {
189
+ const c = T ? U(n, i) : W(n, i, s, x), S = w ? U(s, e) : W(s, e, n, x), E = c.x === S.x || c.y === S.y ? [[c, S]] : [
190
+ [c, { x: S.x, y: c.y }, S],
191
+ [c, { x: c.x, y: S.y }, S]
192
+ ];
193
+ for (const l of E) {
194
+ if (r.includes(n) && !m(c, l[1], i) || r.includes(s) && !m(S, l.at(-2), e) || l.slice(1).some((H, v) => {
195
+ const t = l[v];
196
+ return r.some(
197
+ (o) => Math.max(t.x, H.x) > o.x && Math.min(t.x, H.x) < o.x + o.width && Math.max(t.y, H.y) > o.y && Math.min(t.y, H.y) < o.y + o.height
198
+ );
199
+ }))
200
+ continue;
201
+ const C = l.slice(1).reduce(
202
+ (H, v, t) => H + Math.abs(v.x - l[t].x) + Math.abs(v.y - l[t].y),
203
+ 0
204
+ ) + (l.length - 2) * 32 + (i === p.source ? 0 : 16) + (e === p.target ? 0 : 16);
205
+ (!y || C < y.score) && (y = { source: i, target: e, score: C });
206
+ }
207
+ }
208
+ return y;
209
+ }
210
+ function Y(n, s) {
211
+ const r = (e, c) => c.x >= e.x && c.y >= e.y && c.x + c.width <= e.x + e.width && c.y + c.height <= e.y + e.height, p = r(n, s) ? n : r(s, n) ? s : void 0;
212
+ if (p) {
213
+ const e = p === n ? s : n, c = {
214
+ NORTH: e.y - p.y,
215
+ EAST: p.x + p.width - e.x - e.width,
216
+ SOUTH: p.y + p.height - e.y - e.height,
217
+ WEST: e.x - p.x
218
+ }, S = [...N].sort((E, l) => c[E] - c[l])[0];
219
+ return { source: S, target: S };
220
+ }
221
+ const x = s.x + s.width / 2 - (n.x + n.width / 2), T = s.y + s.height / 2 - (n.y + n.height / 2), w = Math.max(n.x - (s.x + s.width), s.x - (n.x + n.width), 0), y = Math.max(
222
+ n.y - (s.y + s.height),
223
+ s.y - (n.y + n.height),
152
224
  0
153
- ), h = (f === 0 && i > 0 ? !0 : i === 0 && f > 0 ? !1 : i === 0 && f === 0 ? Math.abs(s) >= Math.abs(d) : i <= f) ? s >= 0 ? "EAST" : "WEST" : d >= 0 ? "SOUTH" : "NORTH";
154
- return { source: h, target: O(h) };
225
+ ), i = (y === 0 && w > 0 ? !0 : w === 0 && y > 0 ? !1 : w === 0 && y === 0 ? Math.abs(x) >= Math.abs(T) : w <= y) ? x >= 0 ? "EAST" : "WEST" : T >= 0 ? "SOUTH" : "NORTH";
226
+ return { source: i, target: B(i) };
155
227
  }
156
- function k(t, e, s, d = 0) {
157
- const i = (r) => Math.min(8, r / 4), f = (r, S, P) => Math.max(S + i(P), Math.min(S + P - i(P), r)), T = (r, S, P, R) => {
158
- const l = Math.max(r, P), M = Math.min(r + S, P + R);
159
- return l < M ? (l + M) / 2 + d : void 0;
160
- }, h = s.x + s.width / 2, y = s.y + s.height / 2;
161
- switch (e) {
228
+ function W(n, s, r, p = 0) {
229
+ const x = (i) => Math.min(8, i / 4), T = (i, e, c) => Math.max(e + x(c), Math.min(e + c - x(c), i)), w = (i, e, c, S) => {
230
+ const E = Math.max(i, c), l = Math.min(i + e, c + S);
231
+ return E < l ? (E + l) / 2 + p : void 0;
232
+ }, y = r.x + r.width / 2, m = r.y + r.height / 2;
233
+ switch (s) {
162
234
  case "NORTH":
163
235
  return {
164
- x: f(
165
- T(t.x, t.width, s.x, s.width) ?? h + d,
166
- t.x,
167
- t.width
236
+ x: T(
237
+ w(n.x, n.width, r.x, r.width) ?? y + p,
238
+ n.x,
239
+ n.width
168
240
  ),
169
- y: t.y
241
+ y: n.y
170
242
  };
171
243
  case "EAST":
172
244
  return {
173
- x: t.x + t.width,
174
- y: f(
175
- T(t.y, t.height, s.y, s.height) ?? y + d,
176
- t.y,
177
- t.height
245
+ x: n.x + n.width,
246
+ y: T(
247
+ w(n.y, n.height, r.y, r.height) ?? m + p,
248
+ n.y,
249
+ n.height
178
250
  )
179
251
  };
180
252
  case "SOUTH":
181
253
  return {
182
- x: f(
183
- T(t.x, t.width, s.x, s.width) ?? h + d,
184
- t.x,
185
- t.width
254
+ x: T(
255
+ w(n.x, n.width, r.x, r.width) ?? y + p,
256
+ n.x,
257
+ n.width
186
258
  ),
187
- y: t.y + t.height
259
+ y: n.y + n.height
188
260
  };
189
261
  case "WEST":
190
262
  return {
191
- x: t.x,
192
- y: f(
193
- T(t.y, t.height, s.y, s.height) ?? y + d,
194
- t.y,
195
- t.height
263
+ x: n.x,
264
+ y: T(
265
+ w(n.y, n.height, r.y, r.height) ?? m + p,
266
+ n.y,
267
+ n.height
196
268
  )
197
269
  };
198
270
  }
199
271
  }
200
272
  export {
201
- F as routeGraphGeometry
273
+ $ as routeGraphGeometry
202
274
  };
@@ -23,6 +23,8 @@ export interface RemoteInputOptions<T> {
23
23
  export interface RemoteInputController<T> {
24
24
  readonly element: HTMLTextAreaElement;
25
25
  bindTarget(target: T | null): void;
26
+ /** Physical preserves the host layout; text uses every local confirmed edit. */
27
+ setTextInputMode(mode: 'physical' | 'text'): void;
26
28
  setAnchor(clientX: number, clientY: number): void;
27
29
  focus(): void;
28
30
  setKeyboardVisible(visible: boolean): void;
@@ -1,15 +1,15 @@
1
- function I(a) {
2
- const { surface: M } = a, k = M.ownerDocument, c = k.defaultView;
3
- if (!c) 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", a.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, y = 0, u = !1, V = !1, o = null, p = !1, s = null;
7
- const h = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set();
8
- let C = null;
9
- const E = [];
10
- function n(e, i, r) {
11
- const g = r;
12
- e.addEventListener(i, g), E.push(() => e.removeEventListener(i, g));
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 K(e) {
26
- V !== e && (V = e, a.onKeyboardVisibilityChange?.(e));
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 B() {
38
- const e = l, i = h.size > 0;
39
- h.clear(), e !== null && i && a.release(e);
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 m() {
42
- y++, o && (o.cancelled = !0), p = !0, d(), B(), o && k.activeElement === t && t.blur();
41
+ function y() {
42
+ g++, o && (o.cancelled = !0), m = !0, p(), A(), o && K.activeElement === t && t.blur();
43
43
  }
44
- function T(e) {
45
- !e || l === null || u || a.commitText(e, l);
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 z(e) {
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
- a.sendKey(i, r), l === r && a.sendKey({ ...i, pressed: !1 }, r);
58
+ n.sendKey(i, r), l === r && n.sendKey({ ...i, pressed: !1 }, r);
51
59
  }
52
- function A(e) {
53
- if (l === null || u) {
54
- d();
60
+ function I(e) {
61
+ if (l === null || c) {
62
+ p();
55
63
  return;
56
64
  }
57
- if (o?.cancelled || o && o.epoch !== y) {
58
- d();
65
+ if (o?.cancelled || o && o.epoch !== g) {
66
+ p();
59
67
  return;
60
68
  }
61
69
  if (e.isComposing) {
62
- o ??= { epoch: y, committed: !1, cancelled: !1 }, t.dataset.composing = "true", f();
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, T(t.value)), d();
74
+ !o.committed && t.value && (o.committed = !0, V(t.value)), p();
67
75
  return;
68
76
  }
69
- if (p || e.inputType === "insertFromComposition") {
70
- p = !1, d();
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
- h.add(r.code || r.key), a.sendKey(r, l);
77
- } else T(i);
78
- d();
84
+ f.add(r.code || r.key), n.sendKey(r, l);
85
+ } else V(i);
86
+ p();
79
87
  }
80
- return n(t, "keydown", (e) => {
81
- if (!(l === null || u)) {
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
- w.add(b(e)), s = null;
91
+ M.add(b(e)), s = null;
84
92
  return;
85
93
  }
86
- if (w.delete(b(e)), p = !1, a.clipboard?.(e, l)) {
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(), h.add(b(e)), a.sendKey(x(e, !0), l);
110
+ e.preventDefault(), L(x(e, !0));
99
111
  }
100
- }), n(t, "keyup", (e) => {
101
- e.stopPropagation(), s = null, !w.delete(b(e)) && l !== null && h.delete(b(e)) && a.sendKey(x(e, !1), l);
102
- }), n(t, "beforeinput", (e) => {
103
- if (l === null || u) {
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
- p = !1;
120
+ m = !1;
109
121
  const r = { deleteContentBackward: "Backspace", deleteContentForward: "Delete", insertLineBreak: "Enter", insertParagraph: "Enter" }[e.inputType];
110
- r && (e.preventDefault(), d(), z(r));
111
- }), n(t, "input", A), n(t, "compositionstart", () => {
112
- o = { epoch: y, committed: !1, cancelled: l === null }, p = !1, s = null, t.dataset.composing = "true", f();
113
- }), n(t, "compositionend", (e) => {
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, p = !0, d(), i && !i.cancelled && !i.committed && i.epoch === y && T(e.data);
116
- }), n(t, "blur", () => {
117
- m(), K(!1);
118
- }), n(c, "blur", m), n(c, "pagehide", m), n(c, "resize", f), c.visualViewport && (n(c.visualViewport, "resize", f), n(c.visualViewport, "scroll", f)), f(), {
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
- u || Object.is(l, e) || (m(), l = e, t.disabled = e === null);
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) || (C = { x: e, y: i }, f());
139
+ !Number.isFinite(e) || !Number.isFinite(i) || (T = { x: e, y: i }, d());
125
140
  },
126
141
  focus() {
127
- l === null || u || (t.focus({ preventScroll: !0 }), f());
142
+ l === null || c || (t.focus({ preventScroll: !0 }), d());
128
143
  },
129
144
  setKeyboardVisible(e) {
130
- e && l !== null && !u ? (t.focus({ preventScroll: !0 }), K(!0), f()) : (t.blur(), K(!1));
145
+ e && l !== null && !c ? (t.focus({ preventScroll: !0 }), C(!0), d()) : (t.blur(), C(!1));
131
146
  },
132
- release: B,
133
- reset: m,
147
+ release: A,
148
+ reset: y,
134
149
  dispose() {
135
- if (!u) {
136
- m(), u = !0, l = null;
137
- for (const e of E) e();
138
- t.remove(), K(!1);
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
- I as createRemoteInput
159
+ W as createRemoteInput
145
160
  };
@@ -1,8 +1,9 @@
1
- function R(d) {
2
- const { surface: l } = d, I = l.ownerDocument, c = I.defaultView;
3
- if (!c) throw new Error("Remote pointer requires an attached document");
4
- let o = null, f = null, u = null, p = null, y = 0, z = !1, L = 0, O = 0, H = !1, K = !1, b = 0, D = !1;
5
- const m = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Map(), P = [], k = (e) => !K && d.isTargetValid(e), x = (e, t) => Math.hypot(e.clientX - t.clientX, e.clientY - t.clientY), h = (e) => ({
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 _(e, t) {
19
- const n = k(t) && d.sendPointer(e, t) !== !1;
20
- if (n && e.kind === "move")
21
- for (const i of g.values()) i.target === t && (i.command = { ...i.command, ...h(e) });
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
- c.clearTimeout(O), O = 0, H && (H = !1, d.onHoldChange?.(null));
28
+ r.clearTimeout(z), z = 0, A && (A = !1, f.onHoldChange?.(null));
26
29
  }
27
- function A(e) {
28
- E.delete(e), l.hasPointerCapture?.(e) && l.releasePointerCapture(e);
30
+ function V(e) {
31
+ x.delete(e), c.hasPointerCapture?.(e) && c.releasePointerCapture(e);
29
32
  }
30
- function N(e) {
31
- l.setPointerCapture?.(e), E.add(e);
33
+ function F(e) {
34
+ c.setPointerCapture?.(e), x.add(e);
32
35
  }
33
- function v() {
34
- L++, z = !1, y && c.cancelAnimationFrame(y), y = 0;
35
- const e = f;
36
- f = null, e && !_(e.command, e.target) && r();
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 (f && (f.target !== t || f.command.kind !== e.kind) && v(), !!k(t)) {
40
- if (e.kind === "scroll" && f?.command.kind === "scroll" && (e = { ...e, dx: f.command.dx + e.dx, dy: f.command.dy + e.dy }), f = { target: t, command: e }, e.kind === "move") {
41
- if (!z) {
42
- z = !0;
43
- const n = L;
44
- c.queueMicrotask(() => {
45
- n === L && v();
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 (!y) {
51
- const n = b, i = c.requestAnimationFrame(() => {
52
- n === b && y === i && v();
58
+ if (!w) {
59
+ const n = E, i = r.requestAnimationFrame(() => {
60
+ n === E && w === i && m();
53
61
  });
54
- y = i;
62
+ w = i;
55
63
  }
56
64
  }
57
65
  }
58
- function T(e, t, n, i, s = 1) {
59
- const w = g.get(i);
60
- if (!e && !w) return;
61
- e || g.delete(i);
62
- const M = { ...t, kind: e ? "down" : "up", button: i, clicks: s };
63
- _(M, n) && e && g.set(i, { target: n, command: M });
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 = b;
67
- return d.onActivate?.(e, t), n === b && k(t);
74
+ const n = E;
75
+ return f.onActivate?.(e, t), n === E && T(t);
68
76
  }
69
- function B(e, t, n, i = 1) {
70
- Y(e, t) && (T(!0, e, t, n, i), T(!1, e, t, n, i));
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 r() {
73
- b++, L++, z = !1, X(), y && c.cancelAnimationFrame(y), y = 0;
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), f && e.add(f.target), u !== null && e.add(u), f = null, o = null, u = null, p = null, D = m.size > 0;
76
- for (const [t, n] of g)
77
- e.add(n.target), T(!1, n.command, n.target, t);
78
- for (const t of e) d.release(t);
79
- for (const t of [...E]) A(t);
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 S(e) {
82
- m.delete(e), A(e), m.size || (D = !1);
89
+ function L(e) {
90
+ g.delete(e), V(e), g.size || (D = !1);
83
91
  }
84
- function U(e) {
92
+ function R(e) {
85
93
  const t = o;
86
94
  if (!t || t.id !== e.pointerId) return;
87
- if (!k(t.target)) {
88
- r();
95
+ if (!T(t.target)) {
96
+ l();
89
97
  return;
90
98
  }
91
- const n = h(e);
92
- if ((t.mode === "pending" || t.mode === "hold") && x(t.origin, n) > 8) {
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) && T(!0, t.origin, t.target, 0), o !== t) return;
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, w = i.clientY - n.clientY;
98
- (s || w) && C({ ...t.origin, kind: "scroll", dx: s, dy: w }, t.target), t.last = n;
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(l, "pointerdown", (e) => {
102
- const t = d.resolveTarget(e);
103
- if (t === null || !k(t)) return;
104
- const n = h(e);
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 (m.add(e.pointerId), m.size > 1 || D) {
107
- r();
114
+ if (g.add(e.pointerId), g.size > 1 || D) {
115
+ l();
108
116
  return;
109
117
  }
110
- (o || g.size) && r(), v(), u !== null && (d.release(u), u = null), D = !1, o = { id: e.pointerId, target: t, origin: n, last: n, mode: "pending" };
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
- O = c.setTimeout(() => {
113
- if (O = 0, o === i) {
114
- if (!k(t)) {
115
- r();
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", H = !0, d.onHoldChange?.({ ...n, target: t });
126
+ i.mode = "hold", A = !0, f.onHoldChange?.({ ...n, target: t });
119
127
  }
120
128
  }, 450);
121
129
  } else {
122
- if (m.size) {
123
- r();
130
+ if (g.size) {
131
+ l();
124
132
  return;
125
133
  }
126
- o && (o.id !== e.pointerId || o.target !== t) && r(), v(), u !== null && (d.release(u), u = null), o = { id: e.pointerId, target: t, origin: n, last: n, mode: "direct" };
127
- const i = e.button === 0 && p?.target === t && c.performance.now() - p.time <= 350 && x(p.position, n) <= 16;
128
- Y(n, t) && T(!0, n, t, e.button, Math.max(1, e.detail, i ? 2 : 1));
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
- N(e.pointerId), e.pointerType === "touch" && e.preventDefault();
138
+ F(e.pointerId), e.pointerType === "touch" && e.preventDefault();
131
139
  });
132
- const q = "onpointerrawupdate" in c;
133
- function F(e, t) {
134
- if (D || m.size) return;
135
- const n = o?.target ?? d.resolveTarget(e);
136
- if (n === null || !k(n)) {
137
- o && r();
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 = h(e);
148
+ const i = v(e);
141
149
  if (o) {
142
150
  t && (o.last = i);
143
- for (const [s, w] of [[0, 1], [1, 4], [2, 2], [3, 8], [4, 16]]) {
144
- const M = !!(e.buttons & w);
145
- M !== g.has(s) && (v(), T(M, i, n, s));
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
- q && a(l, "pointerrawupdate", (e) => {
151
- e.pointerType !== "touch" && F(e, !0);
152
- }), a(l, "pointermove", (e) => {
153
- e.pointerType === "touch" ? U(e) : F(e, !q);
154
- }), a(l, "pointerup", (e) => {
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 (!k(t.target)) r();
165
+ if (!T(t.target)) l();
158
166
  else if (e.pointerType === "touch") {
159
- U(e), X();
160
- const n = h(e);
167
+ R(e), X();
168
+ const n = v(e);
161
169
  if (t.mode === "pending") {
162
- const i = c.performance.now(), s = p?.target === t.target && i - p.time <= 350 && x(p.position, n) <= 16;
163
- B(n, t.target, 0, s ? 2 : 1), p = s ? null : { target: t.target, position: n, time: i };
164
- } else t.mode === "hold" ? (p = null, B(n, t.target, 2)) : (v(), t.mode === "drag" && T(!1, n, t.target, 0));
165
- d.release(t.target), o = null;
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
- f?.command.kind === "move" && (f.command = { ...h(e), kind: "move" }), v();
168
- const n = g.get(e.button)?.command;
169
- for (const i of [...g.keys()]) T(!1, h(e), t.target, i, n && "clicks" in n ? n.clicks : 1);
170
- p = e.button === 0 && n && "clicks" in n && n.clicks === 1 && x(t.origin, h(e)) <= 8 ? { target: t.target, position: h(e), time: c.performance.now() } : null, g.size || (o = null);
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) && S(e.pointerId);
173
- }), a(l, "pointercancel", (e) => {
174
- r(), S(e.pointerId);
175
- }), a(l, "lostpointercapture", (e) => {
176
- E.has(e.pointerId) && (r(), S(e.pointerId));
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 && S(e.pointerId);
179
- }), a(I, "pointercancel", (e) => S(e.pointerId)), a(I, "pointerdown", (e) => {
180
- o && (e.pointerType === "touch" && e.pointerId !== o.id ? (m.add(e.pointerId), r()) : l.contains(e.target) || r());
181
- }, !0), a(l, "wheel", (e) => {
182
- const t = d.resolveTarget(e);
183
- if (t === null || !k(t) || (e.preventDefault(), o || m.size)) return;
184
- p = null, u !== null && u !== t && (v(), d.release(u)), u = t;
185
- const n = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? l.clientWidth || c.innerWidth : 1, i = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? l.clientHeight || c.innerHeight : 1, s = e.deltaX * n, w = e.deltaY * i;
186
- Number.isFinite(s) && Number.isFinite(w) && (s || w) && C({ ...h(e), kind: "scroll", dx: s, dy: w }, t);
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(l, e, (t) => {
190
- d.resolveTarget(t) !== null && t.preventDefault();
197
+ a(c, e, (t) => {
198
+ f.resolveTarget(t) !== null && t.preventDefault();
191
199
  });
192
- for (const e of ["blur", "pagehide", "resize", "orientationchange"]) a(c, e, r);
200
+ for (const e of ["blur", "pagehide", "resize", "orientationchange"]) a(r, e, l);
193
201
  if (a(I, "visibilitychange", () => {
194
- I.hidden && r();
195
- }), a(c, "scroll", r, !0), c.visualViewport && (a(c.visualViewport, "resize", r), a(c.visualViewport, "scroll", r)), typeof ResizeObserver < "u") {
196
- let e = `${l.clientWidth}:${l.clientHeight}`;
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 = `${l.clientWidth}:${l.clientHeight}`;
199
- n !== e && (e = n, r());
206
+ const n = `${c.clientWidth}:${c.clientHeight}`;
207
+ n !== e && (e = n, l());
200
208
  });
201
- t.observe(l), P.push(() => t.disconnect());
209
+ t.observe(c), P.push(() => t.disconnect());
202
210
  }
203
- return { flush: v, reset: r, dispose() {
211
+ return { flush: m, reset: l, dispose() {
204
212
  if (!K) {
205
- r(), K = !0;
213
+ l(), K = !0;
206
214
  for (const e of P) e();
207
- m.clear();
215
+ g.clear();
208
216
  }
209
217
  } };
210
218
  }
211
219
  export {
212
- R as createRemotePointer
220
+ $ as createRemotePointer
213
221
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.86.8",
3
+ "version": "0.86.11",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",