react-sync-board 1.1.2 → 1.1.4
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/react-sync-board.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Dr = Object.defineProperty;
|
|
2
2
|
var $r = (e, t, r) => t in e ? Dr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
3
|
var Ot = (e, t, r) => ($r(e, typeof t != "symbol" ? t + "" : t, r), r);
|
|
4
|
-
import m, { useContext as
|
|
4
|
+
import m, { useContext as _e, useDebugValue as Ar, useRef as Ie, useMemo as ct, useEffect as Me, useCallback as Jt, memo as Zt } from "react";
|
|
5
5
|
function Lr(e) {
|
|
6
6
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
7
7
|
}
|
|
@@ -29,14 +29,14 @@ function Yr() {
|
|
|
29
29
|
Tt = 1;
|
|
30
30
|
var e = m, t = Symbol.for("react.element"), r = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, o = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
31
31
|
function a(u, l, d) {
|
|
32
|
-
var f, c = {},
|
|
33
|
-
d !== void 0 && (
|
|
32
|
+
var f, c = {}, _ = null, b = null;
|
|
33
|
+
d !== void 0 && (_ = "" + d), l.key !== void 0 && (_ = "" + l.key), l.ref !== void 0 && (b = l.ref);
|
|
34
34
|
for (f in l)
|
|
35
35
|
n.call(l, f) && !s.hasOwnProperty(f) && (c[f] = l[f]);
|
|
36
36
|
if (u && u.defaultProps)
|
|
37
37
|
for (f in l = u.defaultProps, l)
|
|
38
38
|
c[f] === void 0 && (c[f] = l[f]);
|
|
39
|
-
return { $$typeof: t, type: u, key:
|
|
39
|
+
return { $$typeof: t, type: u, key: _, ref: b, props: c, _owner: o.current };
|
|
40
40
|
}
|
|
41
41
|
return we.Fragment = r, we.jsx = a, we.jsxs = a, we;
|
|
42
42
|
}
|
|
@@ -53,7 +53,7 @@ var Ce = {};
|
|
|
53
53
|
var kt;
|
|
54
54
|
function Br() {
|
|
55
55
|
return kt || (kt = 1, process.env.NODE_ENV !== "production" && function() {
|
|
56
|
-
var e = m, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), o = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), u = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), d = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), c = Symbol.for("react.memo"),
|
|
56
|
+
var e = m, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), o = Symbol.for("react.strict_mode"), s = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), u = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), d = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), c = Symbol.for("react.memo"), _ = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), C = Symbol.iterator, h = "@@iterator";
|
|
57
57
|
function S(i) {
|
|
58
58
|
if (i === null || typeof i != "object")
|
|
59
59
|
return null;
|
|
@@ -81,7 +81,7 @@ function Br() {
|
|
|
81
81
|
var p = !1, R = !1, w = !1, g = !1, k = !1, P;
|
|
82
82
|
P = Symbol.for("react.module.reference");
|
|
83
83
|
function M(i) {
|
|
84
|
-
return !!(typeof i == "string" || typeof i == "function" || i === n || i === s || k || i === o || i === d || i === f || g || i ===
|
|
84
|
+
return !!(typeof i == "string" || typeof i == "function" || i === n || i === s || k || i === o || i === d || i === f || g || i === b || p || R || w || typeof i == "object" && i !== null && (i.$$typeof === _ || i.$$typeof === c || i.$$typeof === a || i.$$typeof === u || i.$$typeof === l || // This needs to include all possible module reference object
|
|
85
85
|
// types supported by any Flight configuration anywhere since
|
|
86
86
|
// we don't know which Flight build this will end up being used
|
|
87
87
|
// with.
|
|
@@ -131,7 +131,7 @@ function Br() {
|
|
|
131
131
|
case c:
|
|
132
132
|
var j = i.displayName || null;
|
|
133
133
|
return j !== null ? j : N(i.type) || "Memo";
|
|
134
|
-
case
|
|
134
|
+
case _: {
|
|
135
135
|
var U = i, W = U._payload, Y = U._init;
|
|
136
136
|
try {
|
|
137
137
|
return N(Y(W));
|
|
@@ -320,7 +320,7 @@ function Br() {
|
|
|
320
320
|
return dr(i.render);
|
|
321
321
|
case c:
|
|
322
322
|
return De(i.type, y, I);
|
|
323
|
-
case
|
|
323
|
+
case _: {
|
|
324
324
|
var j = i, U = j._payload, W = j._init;
|
|
325
325
|
try {
|
|
326
326
|
return De(W(U), y, I);
|
|
@@ -386,7 +386,7 @@ function Br() {
|
|
|
386
386
|
ref: !0,
|
|
387
387
|
__self: !0,
|
|
388
388
|
__source: !0
|
|
389
|
-
}, St,
|
|
389
|
+
}, St, bt, Ke;
|
|
390
390
|
Ke = {};
|
|
391
391
|
function Sr(i) {
|
|
392
392
|
if ($e.call(i, "ref")) {
|
|
@@ -396,7 +396,7 @@ function Br() {
|
|
|
396
396
|
}
|
|
397
397
|
return i.ref !== void 0;
|
|
398
398
|
}
|
|
399
|
-
function
|
|
399
|
+
function br(i) {
|
|
400
400
|
if ($e.call(i, "key")) {
|
|
401
401
|
var y = Object.getOwnPropertyDescriptor(i, "key").get;
|
|
402
402
|
if (y && y.isReactWarning)
|
|
@@ -404,7 +404,7 @@ function Br() {
|
|
|
404
404
|
}
|
|
405
405
|
return i.key !== void 0;
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function _r(i, y) {
|
|
408
408
|
if (typeof i.ref == "string" && Ee.current && y && Ee.current.stateNode !== y) {
|
|
409
409
|
var I = N(Ee.current.type);
|
|
410
410
|
Ke[I] || (x('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', N(Ee.current.type), i.ref), Ke[I] = !0);
|
|
@@ -424,7 +424,7 @@ function Br() {
|
|
|
424
424
|
function wr(i, y) {
|
|
425
425
|
{
|
|
426
426
|
var I = function() {
|
|
427
|
-
|
|
427
|
+
bt || (bt = !0, x("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", y));
|
|
428
428
|
};
|
|
429
429
|
I.isReactWarning = !0, Object.defineProperty(i, "ref", {
|
|
430
430
|
get: I,
|
|
@@ -464,7 +464,7 @@ function Br() {
|
|
|
464
464
|
function xr(i, y, I, j, U) {
|
|
465
465
|
{
|
|
466
466
|
var W, Y = {}, L = null, Q = null;
|
|
467
|
-
I !== void 0 && (yt(I), L = "" + I),
|
|
467
|
+
I !== void 0 && (yt(I), L = "" + I), br(y) && (yt(y.key), L = "" + y.key), Sr(y) && (Q = y.ref, _r(y, U));
|
|
468
468
|
for (W in y)
|
|
469
469
|
$e.call(y, W) && !yr.hasOwnProperty(W) && (Y[W] = y[W]);
|
|
470
470
|
if (i && i.defaultProps) {
|
|
@@ -479,13 +479,13 @@ function Br() {
|
|
|
479
479
|
return Cr(i, L, Q, U, j, Ee.current, Y);
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
|
-
var He = E.ReactCurrentOwner,
|
|
482
|
+
var He = E.ReactCurrentOwner, _t = E.ReactDebugCurrentFrame;
|
|
483
483
|
function ve(i) {
|
|
484
484
|
if (i) {
|
|
485
485
|
var y = i._owner, I = De(i.type, i._source, y ? y.type : null);
|
|
486
|
-
|
|
486
|
+
_t.setExtraStackFrame(I);
|
|
487
487
|
} else
|
|
488
|
-
|
|
488
|
+
_t.setExtraStackFrame(null);
|
|
489
489
|
}
|
|
490
490
|
var qe;
|
|
491
491
|
qe = !1;
|
|
@@ -782,14 +782,14 @@ const Xr = ({
|
|
|
782
782
|
LoadingComponent: n = Wr,
|
|
783
783
|
children: o
|
|
784
784
|
}) => {
|
|
785
|
-
const [s, a] = m.useState(!1), [u, l] = m.useState(!1), [d, f] = m.useState(null), c = m.useRef(null),
|
|
786
|
-
return m.useEffect(() => (
|
|
787
|
-
|
|
785
|
+
const [s, a] = m.useState(!1), [u, l] = m.useState(!1), [d, f] = m.useState(null), c = m.useRef(null), _ = m.useRef(!1), b = _e(ot), C = m.useRef(!1);
|
|
786
|
+
return m.useEffect(() => (_.current = !0, () => {
|
|
787
|
+
_.current = !1;
|
|
788
788
|
}), []), m.useEffect(() => {
|
|
789
789
|
if (!e)
|
|
790
790
|
return null;
|
|
791
791
|
const h = () => {
|
|
792
|
-
console.log(`Disconnected from ${r}…`),
|
|
792
|
+
console.log(`Disconnected from ${r}…`), _.current && (a(!1), l(!1));
|
|
793
793
|
};
|
|
794
794
|
return e.on("disconnect", h), () => {
|
|
795
795
|
e.off("disconnect", h);
|
|
@@ -798,10 +798,10 @@ const Xr = ({
|
|
|
798
798
|
socket: e,
|
|
799
799
|
room: t,
|
|
800
800
|
onMaster: () => {
|
|
801
|
-
console.log(`Is now master on channel ${r}…`),
|
|
801
|
+
console.log(`Is now master on channel ${r}…`), _.current && l(!0);
|
|
802
802
|
},
|
|
803
803
|
onJoined: (h) => {
|
|
804
|
-
console.log(`Connected on channel ${r}…`), c.current = h,
|
|
804
|
+
console.log(`Connected on channel ${r}…`), c.current = h, _.current && (f(h), a(!0));
|
|
805
805
|
}
|
|
806
806
|
})), () => {
|
|
807
807
|
var h;
|
|
@@ -809,17 +809,17 @@ const Xr = ({
|
|
|
809
809
|
}) : null, [r, t, e]), !s || !d ? /* @__PURE__ */ T(n, {}) : /* @__PURE__ */ T(
|
|
810
810
|
ot.Provider,
|
|
811
811
|
{
|
|
812
|
-
value: { ...
|
|
812
|
+
value: { ...b, [r]: { wire: d, joined: s, isMaster: u, room: t } },
|
|
813
813
|
children: o
|
|
814
814
|
}
|
|
815
815
|
);
|
|
816
|
-
}, Be = (e = "default") => (
|
|
816
|
+
}, Be = (e = "default") => (_e(ot) || {})[e], Pt = (e) => {
|
|
817
817
|
let t;
|
|
818
818
|
const r = /* @__PURE__ */ new Set(), n = (l, d) => {
|
|
819
819
|
const f = typeof l == "function" ? l(t) : l;
|
|
820
820
|
if (!Object.is(f, t)) {
|
|
821
821
|
const c = t;
|
|
822
|
-
t = d ?? typeof f != "object" ? f : Object.assign({}, t, f), r.forEach((
|
|
822
|
+
t = d ?? typeof f != "object" ? f : Object.assign({}, t, f), r.forEach((_) => _(t, c));
|
|
823
823
|
}
|
|
824
824
|
}, o = () => t, u = { setState: n, getState: o, subscribe: (l) => (r.add(l), () => r.delete(l)), destroy: () => {
|
|
825
825
|
({ BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0 } && "production") !== "production" && console.warn(
|
|
@@ -858,32 +858,32 @@ function Kr() {
|
|
|
858
858
|
return Ze;
|
|
859
859
|
Mt = 1;
|
|
860
860
|
var e = m;
|
|
861
|
-
function t(c,
|
|
862
|
-
return c ===
|
|
861
|
+
function t(c, _) {
|
|
862
|
+
return c === _ && (c !== 0 || 1 / c === 1 / _) || c !== c && _ !== _;
|
|
863
863
|
}
|
|
864
864
|
var r = typeof Object.is == "function" ? Object.is : t, n = e.useState, o = e.useEffect, s = e.useLayoutEffect, a = e.useDebugValue;
|
|
865
|
-
function u(c,
|
|
866
|
-
var
|
|
865
|
+
function u(c, _) {
|
|
866
|
+
var b = _(), C = n({ inst: { value: b, getSnapshot: _ } }), h = C[0].inst, S = C[1];
|
|
867
867
|
return s(function() {
|
|
868
|
-
h.value =
|
|
869
|
-
}, [c,
|
|
868
|
+
h.value = b, h.getSnapshot = _, l(h) && S({ inst: h });
|
|
869
|
+
}, [c, b, _]), o(function() {
|
|
870
870
|
return l(h) && S({ inst: h }), c(function() {
|
|
871
871
|
l(h) && S({ inst: h });
|
|
872
872
|
});
|
|
873
|
-
}, [c]), a(
|
|
873
|
+
}, [c]), a(b), b;
|
|
874
874
|
}
|
|
875
875
|
function l(c) {
|
|
876
|
-
var
|
|
876
|
+
var _ = c.getSnapshot;
|
|
877
877
|
c = c.value;
|
|
878
878
|
try {
|
|
879
|
-
var
|
|
880
|
-
return !r(c,
|
|
879
|
+
var b = _();
|
|
880
|
+
return !r(c, b);
|
|
881
881
|
} catch {
|
|
882
882
|
return !0;
|
|
883
883
|
}
|
|
884
884
|
}
|
|
885
|
-
function d(c,
|
|
886
|
-
return
|
|
885
|
+
function d(c, _) {
|
|
886
|
+
return _();
|
|
887
887
|
}
|
|
888
888
|
var f = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? d : u;
|
|
889
889
|
return Ze.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : f, Ze;
|
|
@@ -924,7 +924,7 @@ function Hr() {
|
|
|
924
924
|
return v === p && (v !== 0 || 1 / v === 1 / p) || v !== v && p !== p;
|
|
925
925
|
}
|
|
926
926
|
var s = typeof Object.is == "function" ? Object.is : o, a = e.useState, u = e.useEffect, l = e.useLayoutEffect, d = e.useDebugValue, f = !1, c = !1;
|
|
927
|
-
function
|
|
927
|
+
function _(v, p, R) {
|
|
928
928
|
f || e.startTransition !== void 0 && (f = !0, r("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
|
|
929
929
|
var w = p();
|
|
930
930
|
if (!c) {
|
|
@@ -938,22 +938,22 @@ function Hr() {
|
|
|
938
938
|
}
|
|
939
939
|
}), P = k[0].inst, M = k[1];
|
|
940
940
|
return l(function() {
|
|
941
|
-
P.value = w, P.getSnapshot = p,
|
|
941
|
+
P.value = w, P.getSnapshot = p, b(P) && M({
|
|
942
942
|
inst: P
|
|
943
943
|
});
|
|
944
944
|
}, [v, w, p]), u(function() {
|
|
945
|
-
|
|
945
|
+
b(P) && M({
|
|
946
946
|
inst: P
|
|
947
947
|
});
|
|
948
948
|
var $ = function() {
|
|
949
|
-
|
|
949
|
+
b(P) && M({
|
|
950
950
|
inst: P
|
|
951
951
|
});
|
|
952
952
|
};
|
|
953
953
|
return v($);
|
|
954
954
|
}, [v]), d(w), w;
|
|
955
955
|
}
|
|
956
|
-
function
|
|
956
|
+
function b(v) {
|
|
957
957
|
var p = v.getSnapshot, R = v.value;
|
|
958
958
|
try {
|
|
959
959
|
var w = p();
|
|
@@ -965,7 +965,7 @@ function Hr() {
|
|
|
965
965
|
function C(v, p, R) {
|
|
966
966
|
return p();
|
|
967
967
|
}
|
|
968
|
-
var h = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", S = !h, E = S ? C :
|
|
968
|
+
var h = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", S = !h, E = S ? C : _, x = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : E;
|
|
969
969
|
Qe.useSyncExternalStore = x, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
970
970
|
}()), Qe;
|
|
971
971
|
}
|
|
@@ -994,7 +994,7 @@ function qr() {
|
|
|
994
994
|
return d === f && (d !== 0 || 1 / d === 1 / f) || d !== d && f !== f;
|
|
995
995
|
}
|
|
996
996
|
var n = typeof Object.is == "function" ? Object.is : r, o = t.useSyncExternalStore, s = e.useRef, a = e.useEffect, u = e.useMemo, l = e.useDebugValue;
|
|
997
|
-
return Je.useSyncExternalStoreWithSelector = function(d, f, c,
|
|
997
|
+
return Je.useSyncExternalStoreWithSelector = function(d, f, c, _, b) {
|
|
998
998
|
var C = s(null);
|
|
999
999
|
if (C.current === null) {
|
|
1000
1000
|
var h = { hasValue: !1, value: null };
|
|
@@ -1004,17 +1004,17 @@ function qr() {
|
|
|
1004
1004
|
C = u(function() {
|
|
1005
1005
|
function E(w) {
|
|
1006
1006
|
if (!x) {
|
|
1007
|
-
if (x = !0, v = w, w =
|
|
1007
|
+
if (x = !0, v = w, w = _(w), b !== void 0 && h.hasValue) {
|
|
1008
1008
|
var g = h.value;
|
|
1009
|
-
if (
|
|
1009
|
+
if (b(g, w))
|
|
1010
1010
|
return p = g;
|
|
1011
1011
|
}
|
|
1012
1012
|
return p = w;
|
|
1013
1013
|
}
|
|
1014
1014
|
if (g = p, n(v, w))
|
|
1015
1015
|
return g;
|
|
1016
|
-
var k =
|
|
1017
|
-
return
|
|
1016
|
+
var k = _(w);
|
|
1017
|
+
return b !== void 0 && b(g, k) ? g : (v = w, p = k);
|
|
1018
1018
|
}
|
|
1019
1019
|
var x = !1, v, p, R = c === void 0 ? null : c;
|
|
1020
1020
|
return [function() {
|
|
@@ -1022,7 +1022,7 @@ function qr() {
|
|
|
1022
1022
|
}, R === null ? void 0 : function() {
|
|
1023
1023
|
return E(R());
|
|
1024
1024
|
}];
|
|
1025
|
-
}, [f, c,
|
|
1025
|
+
}, [f, c, _, b]);
|
|
1026
1026
|
var S = o(d, C[0], C[1]);
|
|
1027
1027
|
return a(function() {
|
|
1028
1028
|
h.hasValue = !0, h.value = S;
|
|
@@ -1048,7 +1048,7 @@ function Gr() {
|
|
|
1048
1048
|
return f === c && (f !== 0 || 1 / f === 1 / c) || f !== f && c !== c;
|
|
1049
1049
|
}
|
|
1050
1050
|
var n = typeof Object.is == "function" ? Object.is : r, o = t.useSyncExternalStore, s = e.useRef, a = e.useEffect, u = e.useMemo, l = e.useDebugValue;
|
|
1051
|
-
function d(f, c,
|
|
1051
|
+
function d(f, c, _, b, C) {
|
|
1052
1052
|
var h = s(null), S;
|
|
1053
1053
|
h.current === null ? (S = {
|
|
1054
1054
|
hasValue: !1,
|
|
@@ -1058,7 +1058,7 @@ function Gr() {
|
|
|
1058
1058
|
var R = !1, w, g, k = function(B) {
|
|
1059
1059
|
if (!R) {
|
|
1060
1060
|
R = !0, w = B;
|
|
1061
|
-
var N =
|
|
1061
|
+
var N = b(B);
|
|
1062
1062
|
if (C !== void 0 && S.hasValue) {
|
|
1063
1063
|
var K = S.value;
|
|
1064
1064
|
if (C(K, N))
|
|
@@ -1069,15 +1069,15 @@ function Gr() {
|
|
|
1069
1069
|
var O = w, D = g;
|
|
1070
1070
|
if (n(O, B))
|
|
1071
1071
|
return D;
|
|
1072
|
-
var A =
|
|
1072
|
+
var A = b(B);
|
|
1073
1073
|
return C !== void 0 && C(D, A) ? D : (w = B, g = A, A);
|
|
1074
|
-
}, P =
|
|
1074
|
+
}, P = _ === void 0 ? null : _, M = function() {
|
|
1075
1075
|
return k(c());
|
|
1076
1076
|
}, $ = P === null ? void 0 : function() {
|
|
1077
1077
|
return k(P());
|
|
1078
1078
|
};
|
|
1079
1079
|
return [M, $];
|
|
1080
|
-
}, [c,
|
|
1080
|
+
}, [c, _, b, C]), x = E[0], v = E[1], p = o(f, x, v);
|
|
1081
1081
|
return a(function() {
|
|
1082
1082
|
S.hasValue = !0, S.value = p;
|
|
1083
1083
|
}, [p]), l(p), p;
|
|
@@ -1099,7 +1099,7 @@ function Ue(e, t = e.getState, r) {
|
|
|
1099
1099
|
);
|
|
1100
1100
|
return Ar(n), n;
|
|
1101
1101
|
}
|
|
1102
|
-
const
|
|
1102
|
+
const be = (e, t) => e.classList && e.classList.contains(t), Te = (e, t) => be(e, t) ? e : e.parentNode ? Te(e.parentNode, t) : !1, rr = (e, t) => e.x > t.left && e.x < t.left + t.width && e.y > t.top && e.y < t.top + t.height, Qr = (e, t) => Array.from(e.querySelectorAll(".corner")).every((n) => {
|
|
1103
1103
|
const { top: o, left: s } = n.getBoundingClientRect();
|
|
1104
1104
|
return rr({ x: s, y: o }, t);
|
|
1105
1105
|
}), en = (e, t) => {
|
|
@@ -1137,17 +1137,17 @@ const _e = (e, t) => e.classList && e.classList.contains(t), Te = (e, t) => _e(e
|
|
|
1137
1137
|
e + r / 2 - a.x,
|
|
1138
1138
|
t + n / 2 - a.y
|
|
1139
1139
|
];
|
|
1140
|
-
let d, f, c,
|
|
1140
|
+
let d, f, c, _, b, C, h, S, E, x;
|
|
1141
1141
|
const v = s / 1.1547;
|
|
1142
1142
|
switch (o) {
|
|
1143
1143
|
case "grid":
|
|
1144
1144
|
d = Math.round(u / s) * s, f = Math.round(l / s) * s;
|
|
1145
1145
|
break;
|
|
1146
1146
|
case "hexH":
|
|
1147
|
-
c = 2 * v,
|
|
1147
|
+
c = 2 * v, _ = 3 * s, b = Math.round(u / c) * c, h = Math.round(l / _) * _, C = b > u ? b - v : b + v, S = h > l ? h - 1.5 * s : h + 1.5 * s, E = Math.hypot(b - u, h - l), x = Math.hypot(C - u, S - l), E < x ? (d = b, f = h) : (d = C, f = S);
|
|
1148
1148
|
break;
|
|
1149
1149
|
case "hexV":
|
|
1150
|
-
c = 3 * s,
|
|
1150
|
+
c = 3 * s, _ = 2 * v, b = Math.round(u / c) * c, h = Math.round(l / _) * _, C = b > u ? b - 1.5 * s : b + 1.5 * s, S = h > l ? h - v : h + v, E = Math.hypot(b - u, h - l), x = Math.hypot(C - u, S - l), E < x ? (d = b, f = h) : (d = C, f = S);
|
|
1151
1151
|
break;
|
|
1152
1152
|
default:
|
|
1153
1153
|
d = e + r / 2, f = t + n / 2;
|
|
@@ -1192,8 +1192,8 @@ const _e = (e, t) => e.classList && e.classList.contains(t), Te = (e, t) => _e(e
|
|
|
1192
1192
|
const l = [];
|
|
1193
1193
|
(async () => {
|
|
1194
1194
|
try {
|
|
1195
|
-
const
|
|
1196
|
-
rn && console.log("init from peer with value",
|
|
1195
|
+
const b = await e.call(`${t}_getValue`);
|
|
1196
|
+
rn && console.log("init from peer with value", b), s((C) => ({ ...C, ...b }));
|
|
1197
1197
|
} catch {
|
|
1198
1198
|
n !== void 0 && s(n);
|
|
1199
1199
|
}
|
|
@@ -1202,27 +1202,27 @@ const _e = (e, t) => e.classList && e.classList.contains(t), Te = (e, t) => _e(e
|
|
|
1202
1202
|
`${t}_getValue`,
|
|
1203
1203
|
() => Object.fromEntries(
|
|
1204
1204
|
Object.entries(a()).filter(
|
|
1205
|
-
([
|
|
1205
|
+
([b, C]) => typeof C != "function" && !r.includes(b)
|
|
1206
1206
|
)
|
|
1207
1207
|
),
|
|
1208
1208
|
{ invoke: "first" }
|
|
1209
1209
|
)
|
|
1210
1210
|
), l.push(
|
|
1211
|
-
e.subscribe(`${t}_call`, ([
|
|
1212
|
-
c[
|
|
1211
|
+
e.subscribe(`${t}_call`, ([b, C]) => {
|
|
1212
|
+
c[b](...C);
|
|
1213
1213
|
})
|
|
1214
1214
|
), s({ ready: !0 });
|
|
1215
1215
|
})();
|
|
1216
|
-
const f = o(s, a, u), c = { ...f },
|
|
1216
|
+
const f = o(s, a, u), c = { ...f }, _ = Object.fromEntries(
|
|
1217
1217
|
// Send the update message on all method calls
|
|
1218
|
-
Object.entries(f).map(([
|
|
1218
|
+
Object.entries(f).map(([b, C]) => typeof C == "function" && !b.startsWith("get") && !r.includes(b) ? [b, (...S) => {
|
|
1219
1219
|
const E = C(...S);
|
|
1220
|
-
return e.publish(`${t}_call`, [
|
|
1221
|
-
}] : [
|
|
1220
|
+
return e.publish(`${t}_call`, [b, S]), E;
|
|
1221
|
+
}] : [b, C])
|
|
1222
1222
|
);
|
|
1223
|
-
return
|
|
1224
|
-
l.forEach((
|
|
1225
|
-
},
|
|
1223
|
+
return _.unsub = () => {
|
|
1224
|
+
l.forEach((b) => b());
|
|
1225
|
+
}, _;
|
|
1226
1226
|
};
|
|
1227
1227
|
function Xe(e, t) {
|
|
1228
1228
|
if (Object.is(e, t))
|
|
@@ -1333,20 +1333,24 @@ const or = m.createContext(), nn = (e, t) => ({
|
|
|
1333
1333
|
setSessionInfo: (r) => e({ session: r }),
|
|
1334
1334
|
updateSessionInfo: (r) => e((n) => ({ session: { ...n.session, ...r } }))
|
|
1335
1335
|
}), Yt = ({ storeName: e, children: t, defaultValue: r }) => {
|
|
1336
|
-
const { wire: n } = Be("room"), [o] = m.useState(
|
|
1336
|
+
const { wire: n } = Be("room"), [o, s] = m.useState(!1), [a] = m.useState(
|
|
1337
1337
|
() => Ne(
|
|
1338
|
-
ut({ wire: n, storeName: e, defaultValue: r }, (...
|
|
1339
|
-
...nn(...
|
|
1340
|
-
...on(...
|
|
1341
|
-
...sn(...
|
|
1342
|
-
...an(...
|
|
1343
|
-
...cn(...
|
|
1338
|
+
ut({ wire: n, storeName: e, defaultValue: r }, (...u) => ({
|
|
1339
|
+
...nn(...u),
|
|
1340
|
+
...on(...u),
|
|
1341
|
+
...sn(...u),
|
|
1342
|
+
...an(...u),
|
|
1343
|
+
...cn(...u)
|
|
1344
1344
|
}))
|
|
1345
1345
|
)
|
|
1346
1346
|
);
|
|
1347
|
-
return
|
|
1347
|
+
return console.log(a), m.useEffect(() => {
|
|
1348
|
+
const u = a.subscribe((l) => {
|
|
1349
|
+
l.ready && (u(), s(!0));
|
|
1350
|
+
});
|
|
1351
|
+
}, [a]), o ? /* @__PURE__ */ T(or.Provider, { value: a, children: t }) : null;
|
|
1348
1352
|
}, se = (e, t) => {
|
|
1349
|
-
const r =
|
|
1353
|
+
const r = _e(or);
|
|
1350
1354
|
return Ue(r, e, t || Xe);
|
|
1351
1355
|
}, Jo = () => {
|
|
1352
1356
|
const [e, t] = se((n) => [
|
|
@@ -1391,6 +1395,7 @@ const or = m.createContext(), nn = (e, t) => ({
|
|
|
1391
1395
|
translateY: 0,
|
|
1392
1396
|
scale: 1
|
|
1393
1397
|
},
|
|
1398
|
+
// TODO optimize when same value as before
|
|
1394
1399
|
updateBoardState: (r) => e((n) => ({ boardState: { ...n.boardState, ...r } })),
|
|
1395
1400
|
getBoardState: () => t().boardState
|
|
1396
1401
|
}), fn = (e, t) => ({
|
|
@@ -1446,7 +1451,7 @@ const or = m.createContext(), nn = (e, t) => ({
|
|
|
1446
1451
|
);
|
|
1447
1452
|
return /* @__PURE__ */ T(ir.Provider, { value: t, children: e });
|
|
1448
1453
|
}, Z = (e, t) => {
|
|
1449
|
-
const r =
|
|
1454
|
+
const r = _e(ir);
|
|
1450
1455
|
return Ue(r, e, t || Xe);
|
|
1451
1456
|
}, Qo = () => {
|
|
1452
1457
|
const [e] = Z((t) => [t.selection]);
|
|
@@ -1602,13 +1607,13 @@ const Le = 100, Se = 1e3, mn = 0.8, Nt = ({
|
|
|
1602
1607
|
Math.max(p * 0.5, 0.05),
|
|
1603
1608
|
Math.max(p * 10, 10)
|
|
1604
1609
|
];
|
|
1605
|
-
}, [n]),
|
|
1610
|
+
}, [n]), _ = m.useCallback(() => {
|
|
1606
1611
|
const { boardWrapperRect: h, boardSize: S } = n(), { translateX: E, translateY: x, scale: v } = e();
|
|
1607
1612
|
return {
|
|
1608
1613
|
x: (h.width / 2 - E) / v - S / 2,
|
|
1609
1614
|
y: (h.height / 2 - x) / v - S / 2
|
|
1610
1615
|
};
|
|
1611
|
-
}, [e, n]),
|
|
1616
|
+
}, [e, n]), b = m.useCallback(() => {
|
|
1612
1617
|
const h = a(), { boardWrapperRect: S, boardWrapper: E, boardSize: x } = n(), { scale: v, translateX: p, translateY: R } = e(), { left: w, top: g, width: k, height: P } = nr(
|
|
1613
1618
|
h.map(({ id: $ }) => $),
|
|
1614
1619
|
E
|
|
@@ -1633,8 +1638,8 @@ const Le = 100, Se = 1e3, mn = 0.8, Nt = ({
|
|
|
1633
1638
|
}
|
|
1634
1639
|
o({ itemExtent: M });
|
|
1635
1640
|
}, [e, n, a, o]), C = ft(
|
|
1636
|
-
() =>
|
|
1637
|
-
[
|
|
1641
|
+
() => b(),
|
|
1642
|
+
[b],
|
|
1638
1643
|
200
|
|
1639
1644
|
);
|
|
1640
1645
|
return m.useEffect(() => {
|
|
@@ -1645,7 +1650,7 @@ const Le = 100, Se = 1e3, mn = 0.8, Nt = ({
|
|
|
1645
1650
|
zoomTo: d,
|
|
1646
1651
|
zoomToCenter: d,
|
|
1647
1652
|
zoomToExtent: f,
|
|
1648
|
-
getCenter:
|
|
1653
|
+
getCenter: _,
|
|
1649
1654
|
updateItemExtent: C
|
|
1650
1655
|
};
|
|
1651
1656
|
}, gn = (e) => {
|
|
@@ -1679,8 +1684,8 @@ const Le = 100, Se = 1e3, mn = 0.8, Nt = ({
|
|
|
1679
1684
|
setItemIds: d,
|
|
1680
1685
|
updateItems: f,
|
|
1681
1686
|
moveItems: c,
|
|
1682
|
-
removeItemsById:
|
|
1683
|
-
getItemList:
|
|
1687
|
+
removeItemsById: _,
|
|
1688
|
+
getItemList: b,
|
|
1684
1689
|
insertItems: C,
|
|
1685
1690
|
setItemList: h
|
|
1686
1691
|
} = se(
|
|
@@ -1818,9 +1823,9 @@ const Le = 100, Se = 1e3, mn = 0.8, Nt = ({
|
|
|
1818
1823
|
[M]
|
|
1819
1824
|
), B = m.useCallback(
|
|
1820
1825
|
(O) => {
|
|
1821
|
-
s(O),
|
|
1826
|
+
s(O), _(O);
|
|
1822
1827
|
},
|
|
1823
|
-
[s,
|
|
1828
|
+
[s, _]
|
|
1824
1829
|
), N = m.useCallback(
|
|
1825
1830
|
(O) => {
|
|
1826
1831
|
const D = u();
|
|
@@ -1833,18 +1838,18 @@ const Le = 100, Se = 1e3, mn = 0.8, Nt = ({
|
|
|
1833
1838
|
return null;
|
|
1834
1839
|
const F = Te(O, "item");
|
|
1835
1840
|
if (F) {
|
|
1836
|
-
if (
|
|
1841
|
+
if (be(F, "selected"))
|
|
1837
1842
|
return F;
|
|
1838
|
-
if (!z &&
|
|
1843
|
+
if (!z && be(F, "locked") && !be(O, "passthrough"))
|
|
1839
1844
|
return X ? F : null;
|
|
1840
|
-
if (
|
|
1845
|
+
if (be(O, "passthrough")) {
|
|
1841
1846
|
const H = l(), { boardWrapper: te } = a(), re = H.reduce((ne, V) => {
|
|
1842
1847
|
const ee = it(te, V), fe = ee.getBoundingClientRect();
|
|
1843
1848
|
return rr({ x: D, y: A }, fe) && ne.unshift(ee), ne;
|
|
1844
1849
|
}, []);
|
|
1845
1850
|
for (let ne = 0; ne < re.length; ne += 1) {
|
|
1846
1851
|
const V = re[ne];
|
|
1847
|
-
if (V !== F && (z || !
|
|
1852
|
+
if (V !== F && (z || !be(V, "locked")))
|
|
1848
1853
|
return V;
|
|
1849
1854
|
}
|
|
1850
1855
|
return null;
|
|
@@ -1867,7 +1872,7 @@ const Le = 100, Se = 1e3, mn = 0.8, Nt = ({
|
|
|
1867
1872
|
pushItem: $,
|
|
1868
1873
|
pushItems: M,
|
|
1869
1874
|
removeItems: B,
|
|
1870
|
-
getItemList:
|
|
1875
|
+
getItemList: b,
|
|
1871
1876
|
findElementUnderPointer: K,
|
|
1872
1877
|
getItems: N
|
|
1873
1878
|
};
|
|
@@ -1960,26 +1965,26 @@ const yn = (e, t) => {
|
|
|
1960
1965
|
}), []);
|
|
1961
1966
|
const d = m.useCallback(
|
|
1962
1967
|
(c) => {
|
|
1963
|
-
const
|
|
1968
|
+
const _ = t();
|
|
1964
1969
|
if (c)
|
|
1965
|
-
return [c, c.map((C) =>
|
|
1966
|
-
const
|
|
1967
|
-
return [
|
|
1970
|
+
return [c, c.map((C) => _[C])];
|
|
1971
|
+
const b = o();
|
|
1972
|
+
return [b, b.map((C) => _[C])];
|
|
1968
1973
|
},
|
|
1969
1974
|
[t, o]
|
|
1970
1975
|
), f = Jt(() => {
|
|
1971
|
-
const [c,
|
|
1976
|
+
const [c, _] = d();
|
|
1972
1977
|
if (c.length > 0) {
|
|
1973
1978
|
if (!u.current)
|
|
1974
1979
|
return;
|
|
1975
|
-
const
|
|
1980
|
+
const b = _.reduce((C, h) => {
|
|
1976
1981
|
const S = Ut(h, r);
|
|
1977
1982
|
return C.filter(
|
|
1978
1983
|
(E) => S.some((x) => hn(E, x))
|
|
1979
1984
|
);
|
|
1980
|
-
}, Ut(
|
|
1985
|
+
}, Ut(_[0], r));
|
|
1981
1986
|
l(() => {
|
|
1982
|
-
a(
|
|
1987
|
+
a(b);
|
|
1983
1988
|
});
|
|
1984
1989
|
} else
|
|
1985
1990
|
l(() => {
|
|
@@ -2016,7 +2021,7 @@ const ar = m.createContext(), at = (e) => {
|
|
|
2016
2021
|
uid: me()
|
|
2017
2022
|
};
|
|
2018
2023
|
return at(e), e;
|
|
2019
|
-
},
|
|
2024
|
+
}, bn = (e) => (t, r) => ({
|
|
2020
2025
|
isSpaceMaster: !1,
|
|
2021
2026
|
users: {},
|
|
2022
2027
|
getUser: () => r().users[e],
|
|
@@ -2061,7 +2066,7 @@ const ar = m.createContext(), at = (e) => {
|
|
|
2061
2066
|
s < o.timestamp && (o.id = a, o.timestamp = s);
|
|
2062
2067
|
}), t({ isSpaceMaster: o.id === e });
|
|
2063
2068
|
}
|
|
2064
|
-
}),
|
|
2069
|
+
}), _n = (e) => ({
|
|
2065
2070
|
cursors: {},
|
|
2066
2071
|
moveCursor: (t, r) => e((n) => ({ cursors: { ...n.cursors, [t]: r } })),
|
|
2067
2072
|
removeCursor: (t) => e((r) => {
|
|
@@ -2075,7 +2080,7 @@ const ar = m.createContext(), at = (e) => {
|
|
|
2075
2080
|
const f = [];
|
|
2076
2081
|
if (!o && !l.current)
|
|
2077
2082
|
return l.current = !0, (() => {
|
|
2078
|
-
const
|
|
2083
|
+
const _ = Ne(
|
|
2079
2084
|
ut(
|
|
2080
2085
|
{
|
|
2081
2086
|
wire: r,
|
|
@@ -2088,15 +2093,15 @@ const ar = m.createContext(), at = (e) => {
|
|
|
2088
2093
|
]
|
|
2089
2094
|
},
|
|
2090
2095
|
(...C) => ({
|
|
2091
|
-
...
|
|
2092
|
-
...
|
|
2096
|
+
...bn(r.userId)(...C),
|
|
2097
|
+
..._n(...C)
|
|
2093
2098
|
})
|
|
2094
2099
|
)
|
|
2095
|
-
),
|
|
2096
|
-
C.ready && (
|
|
2100
|
+
), b = _.subscribe((C) => {
|
|
2101
|
+
C.ready && (b(), d && s(_));
|
|
2097
2102
|
});
|
|
2098
2103
|
})(), () => {
|
|
2099
|
-
d = !1, l.current = !1, f.forEach((
|
|
2104
|
+
d = !1, l.current = !1, f.forEach((_) => _());
|
|
2100
2105
|
};
|
|
2101
2106
|
}, [o, e, r, r.userId]), m.useEffect(() => {
|
|
2102
2107
|
if (o)
|
|
@@ -2119,7 +2124,7 @@ const ar = m.createContext(), at = (e) => {
|
|
|
2119
2124
|
n && o && o.getState().updateCurrentUser({ isMaster: n });
|
|
2120
2125
|
}, [n, o, r]), a ? /* @__PURE__ */ T(ar.Provider, { value: o, children: t }) : null;
|
|
2121
2126
|
}, ge = (e, t) => {
|
|
2122
|
-
const r =
|
|
2127
|
+
const r = _e(ar);
|
|
2123
2128
|
return Ue(r, e, t || Xe);
|
|
2124
2129
|
}, rs = () => {
|
|
2125
2130
|
const [e, t, r, n, o] = ge((u) => [
|
|
@@ -2208,7 +2213,7 @@ const ar = m.createContext(), at = (e) => {
|
|
|
2208
2213
|
);
|
|
2209
2214
|
return /* @__PURE__ */ T(ur.Provider, { value: o, children: t });
|
|
2210
2215
|
}, Cn = (e, t) => {
|
|
2211
|
-
const r =
|
|
2216
|
+
const r = _e(ur);
|
|
2212
2217
|
return Ue(r, e, t || Xe);
|
|
2213
2218
|
}, xn = () => {
|
|
2214
2219
|
}, is = (e = xn) => {
|
|
@@ -2350,7 +2355,7 @@ const ie = new Pn(), We = ({
|
|
|
2350
2355
|
moving: !1,
|
|
2351
2356
|
pointers: {},
|
|
2352
2357
|
mainPointer: void 0
|
|
2353
|
-
}),
|
|
2358
|
+
}), _ = (E) => {
|
|
2354
2359
|
const {
|
|
2355
2360
|
deltaX: x,
|
|
2356
2361
|
deltaY: v,
|
|
@@ -2387,7 +2392,7 @@ const ie = new Pn(), We = ({
|
|
|
2387
2392
|
}
|
|
2388
2393
|
tt() && ($ *= 2), ie.add(l, { scale: $, clientX: p, clientY: R, event: E });
|
|
2389
2394
|
}
|
|
2390
|
-
},
|
|
2395
|
+
}, b = (E) => {
|
|
2391
2396
|
const {
|
|
2392
2397
|
target: x,
|
|
2393
2398
|
button: v,
|
|
@@ -2486,7 +2491,7 @@ const ie = new Pn(), We = ({
|
|
|
2486
2491
|
B = v, N = p;
|
|
2487
2492
|
let O = w || R || g || k || P !== 1;
|
|
2488
2493
|
d !== "drag" && (O = !O);
|
|
2489
|
-
const D =
|
|
2494
|
+
const D = !O, A = O;
|
|
2490
2495
|
if (D) {
|
|
2491
2496
|
c.current.gestureStart || (f.current.style.cursor = "move", c.current.gestureStart = !0, clearTimeout(c.current.longTapTimeout), ie.add(r, {
|
|
2492
2497
|
deltaX: 0,
|
|
@@ -2607,8 +2612,8 @@ const ie = new Pn(), We = ({
|
|
|
2607
2612
|
return /* @__PURE__ */ T(
|
|
2608
2613
|
"div",
|
|
2609
2614
|
{
|
|
2610
|
-
onWheel:
|
|
2611
|
-
onPointerDown:
|
|
2615
|
+
onWheel: _,
|
|
2616
|
+
onPointerDown: b,
|
|
2612
2617
|
onPointerMove: C,
|
|
2613
2618
|
onPointerUp: h,
|
|
2614
2619
|
onPointerOut: h,
|
|
@@ -2667,10 +2672,10 @@ let Mn = { data: "" }, jn = (e) => typeof window == "object" ? ((e ? e.querySele
|
|
|
2667
2672
|
})(s));
|
|
2668
2673
|
if (!ce[a]) {
|
|
2669
2674
|
let l = s !== e ? e : ((d) => {
|
|
2670
|
-
let f, c,
|
|
2675
|
+
let f, c, _ = [{}];
|
|
2671
2676
|
for (; f = Dn.exec(d.replace($n, "")); )
|
|
2672
|
-
f[4] ?
|
|
2673
|
-
return
|
|
2677
|
+
f[4] ? _.shift() : f[3] ? (c = f[3].replace(Kt, " ").trim(), _.unshift(_[0][c] = _[0][c] || {})) : _[0][f[1]] = f[2].replace(Kt, " ").trim();
|
|
2678
|
+
return _[0];
|
|
2674
2679
|
})(e);
|
|
2675
2680
|
ce[a] = de(o ? { ["@keyframes " + a]: l } : l, r ? "" : "." + a);
|
|
2676
2681
|
}
|
|
@@ -2859,8 +2864,8 @@ const Zn = (e) => {
|
|
|
2859
2864
|
}) => {
|
|
2860
2865
|
var w;
|
|
2861
2866
|
const c = m.useRef(null), {
|
|
2862
|
-
component:
|
|
2863
|
-
resizeDirections:
|
|
2867
|
+
component: _ = () => null,
|
|
2868
|
+
resizeDirections: b = eo,
|
|
2864
2869
|
resize: C = Qn
|
|
2865
2870
|
} = d[t], h = m.useCallback(
|
|
2866
2871
|
(g) => e(n, g),
|
|
@@ -2911,7 +2916,7 @@ const Zn = (e) => {
|
|
|
2911
2916
|
itemId: n,
|
|
2912
2917
|
state: a,
|
|
2913
2918
|
ErrorComponent: ((w = d == null ? void 0 : d.error) == null ? void 0 : w.component) || Gn,
|
|
2914
|
-
children: /* @__PURE__ */ T(
|
|
2919
|
+
children: /* @__PURE__ */ T(_, { ...a, id: n, setState: h })
|
|
2915
2920
|
}
|
|
2916
2921
|
),
|
|
2917
2922
|
/* @__PURE__ */ T("div", { className: `corner ${xe} ${Un}` }),
|
|
@@ -2920,21 +2925,21 @@ const Zn = (e) => {
|
|
|
2920
2925
|
/* @__PURE__ */ T("div", { className: `corner ${xe} ${Wn}` }),
|
|
2921
2926
|
/* @__PURE__ */ T("div", { className: `${xe} ${Fn}` }),
|
|
2922
2927
|
f && /* @__PURE__ */ le(Qt, { children: [
|
|
2923
|
-
|
|
2928
|
+
b.b && /* @__PURE__ */ T(
|
|
2924
2929
|
rt,
|
|
2925
2930
|
{
|
|
2926
2931
|
className: `${nt} ${qn}`,
|
|
2927
2932
|
onResize: R
|
|
2928
2933
|
}
|
|
2929
2934
|
),
|
|
2930
|
-
|
|
2935
|
+
b.h && /* @__PURE__ */ T(
|
|
2931
2936
|
rt,
|
|
2932
2937
|
{
|
|
2933
2938
|
className: `${nt} ${Hn}`,
|
|
2934
2939
|
onResize: p
|
|
2935
2940
|
}
|
|
2936
2941
|
),
|
|
2937
|
-
|
|
2942
|
+
b.w && /* @__PURE__ */ T(
|
|
2938
2943
|
rt,
|
|
2939
2944
|
{
|
|
2940
2945
|
className: `${nt} ${Kn}`,
|
|
@@ -3086,7 +3091,7 @@ const fo = q({
|
|
|
3086
3091
|
g.getConfiguration,
|
|
3087
3092
|
g.getBoardState,
|
|
3088
3093
|
g.updateBoardState
|
|
3089
|
-
]), { findElementUnderPointer: d } = pt(), [f] = se((g) => [g.getItems]), [c,
|
|
3094
|
+
]), { findElementUnderPointer: d } = pt(), [f] = se((g) => [g.getItems]), [c, _] = m.useState({}), [, b] = m.useTransition(), [C, h] = m.useState(!1), S = m.useRef(null), E = m.useRef({
|
|
3090
3095
|
moving: !1
|
|
3091
3096
|
});
|
|
3092
3097
|
return ue(document, "keydown", (g) => {
|
|
@@ -3098,7 +3103,7 @@ const fo = q({
|
|
|
3098
3103
|
}), [n]), m.useEffect(() => {
|
|
3099
3104
|
if (E.current.moving) {
|
|
3100
3105
|
const g = f(), { boardWrapper: k } = a(), P = po(g, k, C);
|
|
3101
|
-
|
|
3106
|
+
b(() => {
|
|
3102
3107
|
o(P);
|
|
3103
3108
|
});
|
|
3104
3109
|
}
|
|
@@ -3106,20 +3111,20 @@ const fo = q({
|
|
|
3106
3111
|
We,
|
|
3107
3112
|
{
|
|
3108
3113
|
onDragStart: async (g) => {
|
|
3109
|
-
await d(g) || (E.current.moving = !0,
|
|
3114
|
+
await d(g) || (E.current.moving = !0, b(() => {
|
|
3110
3115
|
l({ selecting: !0 });
|
|
3111
3116
|
}), S.current.style.cursor = "crosshair");
|
|
3112
3117
|
},
|
|
3113
3118
|
onDrag: ({ distanceY: g, distanceX: k, startX: P, startY: M }) => {
|
|
3114
3119
|
if (E.current.moving) {
|
|
3115
3120
|
const { top: $, left: B } = S.current.getBoundingClientRect(), { scale: N } = u(), K = (P - B) / N, O = (M - $) / N, D = k / N, A = g / N;
|
|
3116
|
-
D > 0 ? (E.current.left = K, E.current.width = D) : (E.current.left = K + D, E.current.width = -D), A > 0 ? (E.current.top = O, E.current.height = A) : (E.current.top = O + A, E.current.height = -A),
|
|
3121
|
+
D > 0 ? (E.current.left = K, E.current.width = D) : (E.current.left = K + D, E.current.width = -D), A > 0 ? (E.current.top = O, E.current.height = A) : (E.current.top = O + A, E.current.height = -A), _({ ...E.current, moving: !0 });
|
|
3117
3122
|
}
|
|
3118
3123
|
},
|
|
3119
3124
|
onDragEnd: () => {
|
|
3120
|
-
E.current.moving && (
|
|
3125
|
+
E.current.moving && (b(() => {
|
|
3121
3126
|
l({ selecting: !1 });
|
|
3122
|
-
}), E.current.moving = !1,
|
|
3127
|
+
}), E.current.moving = !1, _({ moving: !1 }), S.current.style.cursor = "auto");
|
|
3123
3128
|
},
|
|
3124
3129
|
onTap: (g) => {
|
|
3125
3130
|
const { target: k, ctrlKey: P, metaKey: M } = g, $ = d(g);
|
|
@@ -3168,7 +3173,7 @@ const fo = q({
|
|
|
3168
3173
|
S.updateBoardState
|
|
3169
3174
|
]), [d] = se((S) => [S.getBoardConfig]), f = m.useRef({}), c = m.useRef({
|
|
3170
3175
|
items: []
|
|
3171
|
-
}),
|
|
3176
|
+
}), _ = (S) => {
|
|
3172
3177
|
const { ctrlKey: E, metaKey: x, event: v } = S, p = n(S);
|
|
3173
3178
|
if (p) {
|
|
3174
3179
|
v.stopPropagation();
|
|
@@ -3181,18 +3186,18 @@ const fo = q({
|
|
|
3181
3186
|
remainY: 0
|
|
3182
3187
|
});
|
|
3183
3188
|
}
|
|
3184
|
-
},
|
|
3189
|
+
}, b = ({ deltaX: S, deltaY: E, event: x }) => {
|
|
3185
3190
|
if (f.current.moving) {
|
|
3186
3191
|
x.stopPropagation();
|
|
3187
|
-
const { scale: v } = u(),
|
|
3192
|
+
const { scale: v, movingItems: p } = u(), R = f.current.remainX + S / v, w = f.current.remainY + E / v;
|
|
3188
3193
|
t(
|
|
3189
3194
|
c.current.items,
|
|
3190
3195
|
{
|
|
3191
|
-
x:
|
|
3192
|
-
y:
|
|
3196
|
+
x: R,
|
|
3197
|
+
y: w
|
|
3193
3198
|
},
|
|
3194
3199
|
!0
|
|
3195
|
-
), l({ movingItems: !0 });
|
|
3200
|
+
), p || l({ movingItems: !0 });
|
|
3196
3201
|
}
|
|
3197
3202
|
}, C = () => {
|
|
3198
3203
|
if (f.current.moving) {
|
|
@@ -3236,7 +3241,7 @@ const fo = q({
|
|
|
3236
3241
|
size: x || 1
|
|
3237
3242
|
}), S.preventDefault());
|
|
3238
3243
|
}
|
|
3239
|
-
}), /* @__PURE__ */ T(We, { onDragStart:
|
|
3244
|
+
}), /* @__PURE__ */ T(We, { onDragStart: _, onDrag: b, onDragEnd: C, children: e });
|
|
3240
3245
|
}, ho = (e) => {
|
|
3241
3246
|
const t = m.useRef({ hover: !1, x: 0, y: 0 });
|
|
3242
3247
|
return ue(e.current, "mousemove", (n) => {
|
|
@@ -3278,17 +3283,17 @@ const fo = q({
|
|
|
3278
3283
|
p.getConfiguration,
|
|
3279
3284
|
p.updateBoardState,
|
|
3280
3285
|
p.getSelection
|
|
3281
|
-
]), { setDim: l, zoomToCenter: d, zoomToExtent: f } = dt(), [c,
|
|
3286
|
+
]), { setDim: l, zoomToCenter: d, zoomToExtent: f } = dt(), [c, _] = m.useState(!1), b = m.useRef({}), C = ho(r);
|
|
3282
3287
|
yo();
|
|
3283
3288
|
const h = m.useCallback(() => {
|
|
3284
3289
|
const { itemExtent: p } = s();
|
|
3285
3290
|
f(p);
|
|
3286
3291
|
}, [s, f]);
|
|
3287
3292
|
m.useEffect(() => {
|
|
3288
|
-
!c && o.left && (h(),
|
|
3293
|
+
!c && o.left && (h(), _(!0));
|
|
3289
3294
|
}, [h, c, o]);
|
|
3290
3295
|
const S = ({ clientX: p, clientY: R, scale: w }) => {
|
|
3291
|
-
d(1 - w / 500, { x: p, y: R }), clearTimeout(
|
|
3296
|
+
d(1 - w / 500, { x: p, y: R }), clearTimeout(b.current.zoom), b.current.zoom = setTimeout(() => {
|
|
3292
3297
|
a({ zooming: !1 });
|
|
3293
3298
|
}, 200), a({ zooming: !0 });
|
|
3294
3299
|
}, E = ({ deltaX: p, deltaY: R }) => {
|
|
@@ -3296,7 +3301,7 @@ const fo = q({
|
|
|
3296
3301
|
...w,
|
|
3297
3302
|
translateX: w.translateX + p,
|
|
3298
3303
|
translateY: w.translateY + R
|
|
3299
|
-
})), clearTimeout(
|
|
3304
|
+
})), clearTimeout(b.current.pan), b.current.pan = setTimeout(() => {
|
|
3300
3305
|
a({ panning: !1 });
|
|
3301
3306
|
}, 200), a({ panning: !0 });
|
|
3302
3307
|
}, x = (p) => {
|
|
@@ -3358,7 +3363,7 @@ const fo = q({
|
|
|
3358
3363
|
)
|
|
3359
3364
|
}
|
|
3360
3365
|
);
|
|
3361
|
-
},
|
|
3366
|
+
}, bo = q({
|
|
3362
3367
|
position: "absolute",
|
|
3363
3368
|
top: 0,
|
|
3364
3369
|
left: 0,
|
|
@@ -3366,7 +3371,7 @@ const fo = q({
|
|
|
3366
3371
|
backgroundColor: "hsla(0, 40%, 50%, 0%)",
|
|
3367
3372
|
border: "2px dashed hsl(20, 55%, 40%)",
|
|
3368
3373
|
pointerEvents: "none"
|
|
3369
|
-
}),
|
|
3374
|
+
}), _o = () => {
|
|
3370
3375
|
const [
|
|
3371
3376
|
e,
|
|
3372
3377
|
t,
|
|
@@ -3386,19 +3391,19 @@ const fo = q({
|
|
|
3386
3391
|
scale: c.boardState.scale
|
|
3387
3392
|
}
|
|
3388
3393
|
]), [l] = se((c) => [c.items]), d = m.useCallback(() => {
|
|
3389
|
-
const c = t(), { boardWrapperRect:
|
|
3394
|
+
const c = t(), { boardWrapperRect: _, boardWrapper: b } = o();
|
|
3390
3395
|
if (c.length === 0) {
|
|
3391
3396
|
n(null);
|
|
3392
3397
|
return;
|
|
3393
3398
|
}
|
|
3394
|
-
const C = nr(c,
|
|
3399
|
+
const C = nr(c, b);
|
|
3395
3400
|
if (!C) {
|
|
3396
3401
|
n(null);
|
|
3397
3402
|
return;
|
|
3398
3403
|
}
|
|
3399
3404
|
const { left: h, top: S, width: E, height: x } = C, v = {
|
|
3400
|
-
left: h -
|
|
3401
|
-
top: S -
|
|
3405
|
+
left: h - _.left,
|
|
3406
|
+
top: S - _.top,
|
|
3402
3407
|
height: x,
|
|
3403
3408
|
width: E
|
|
3404
3409
|
};
|
|
@@ -3422,12 +3427,12 @@ const fo = q({
|
|
|
3422
3427
|
height: `${r.height}px`,
|
|
3423
3428
|
width: `${r.width}px`
|
|
3424
3429
|
},
|
|
3425
|
-
className: `selection ${
|
|
3430
|
+
className: `selection ${bo}`
|
|
3426
3431
|
}
|
|
3427
3432
|
);
|
|
3428
3433
|
}, Eo = () => {
|
|
3429
3434
|
const [e] = Z((t) => [t.boardState.movingItems]);
|
|
3430
|
-
return e ? null : /* @__PURE__ */ T(
|
|
3435
|
+
return e ? null : /* @__PURE__ */ T(_o, {});
|
|
3431
3436
|
}, wo = typeof window < "u" && typeof navigator < "u" && typeof document < "u";
|
|
3432
3437
|
let ze;
|
|
3433
3438
|
function Co() {
|
|
@@ -3536,8 +3541,8 @@ const Pe = (e, t) => Array.from(Array(t)).map(() => e).join(""), Po = new RegExp
|
|
|
3536
3541
|
const o = (e % 360 + 360) % 360 / 60, s = (1 - Math.abs(2 * n - 1)) * (t / 100), a = s * (1 - Math.abs(o % 2 - 1));
|
|
3537
3542
|
let u = 0, l = 0, d = 0;
|
|
3538
3543
|
o >= 0 && o < 1 ? (u = s, l = a) : o >= 1 && o < 2 ? (u = a, l = s) : o >= 2 && o < 3 ? (l = s, d = a) : o >= 3 && o < 4 ? (l = a, d = s) : o >= 4 && o < 5 ? (u = a, d = s) : o >= 5 && o < 6 && (u = s, d = a);
|
|
3539
|
-
const f = n - s / 2, c = u + f,
|
|
3540
|
-
return [c,
|
|
3544
|
+
const f = n - s / 2, c = u + f, _ = l + f, b = d + f;
|
|
3545
|
+
return [c, _, b].map(Gt);
|
|
3541
3546
|
};
|
|
3542
3547
|
function Lo(e) {
|
|
3543
3548
|
if (e === "transparent")
|
|
@@ -3656,11 +3661,11 @@ const Yo = q({
|
|
|
3656
3661
|
l.getBoardState
|
|
3657
3662
|
]);
|
|
3658
3663
|
return /* @__PURE__ */ le("div", { onPointerMove: ({ clientX: l, clientY: d }) => {
|
|
3659
|
-
const { scale: f, translateX: c, translateY:
|
|
3660
|
-
boardWrapperRect: { left:
|
|
3664
|
+
const { scale: f, translateX: c, translateY: _ } = s(), {
|
|
3665
|
+
boardWrapperRect: { left: b, top: C }
|
|
3661
3666
|
} = o(), h = {
|
|
3662
|
-
x: (l -
|
|
3663
|
-
y: (d - C -
|
|
3667
|
+
x: (l - b - c) / f,
|
|
3668
|
+
y: (d - C - _) / f
|
|
3664
3669
|
};
|
|
3665
3670
|
r(t.id, h);
|
|
3666
3671
|
}, onPointerLeave: () => {
|
|
@@ -3686,7 +3691,7 @@ const Yo = q({
|
|
|
3686
3691
|
const l = m.useRef(null), [d, f] = Z((C) => [
|
|
3687
3692
|
C.config.uid,
|
|
3688
3693
|
C.updateConfiguration
|
|
3689
|
-
]), { updateItemExtent: c } = dt(),
|
|
3694
|
+
]), { updateItemExtent: c } = dt(), _ = {
|
|
3690
3695
|
userSelect: "none",
|
|
3691
3696
|
width: `${o}px`,
|
|
3692
3697
|
height: `${o}px`,
|
|
@@ -3723,13 +3728,13 @@ const Yo = q({
|
|
|
3723
3728
|
boardWrapperRect: l.current.getBoundingClientRect()
|
|
3724
3729
|
});
|
|
3725
3730
|
});
|
|
3726
|
-
const
|
|
3731
|
+
const b = q({ ...Ho, ...r });
|
|
3727
3732
|
return /* @__PURE__ */ le(
|
|
3728
3733
|
"div",
|
|
3729
3734
|
{
|
|
3730
3735
|
ref: l,
|
|
3731
3736
|
id: d,
|
|
3732
|
-
className: `sync-board ${
|
|
3737
|
+
className: `sync-board ${b}`,
|
|
3733
3738
|
children: [
|
|
3734
3739
|
/* @__PURE__ */ T(So, { moveFirst: e, children: /* @__PURE__ */ T(mo, { moveFirst: e, children: /* @__PURE__ */ T(go, { moveFirst: e, children: /* @__PURE__ */ T(Fo, { children: /* @__PURE__ */ T(u, { children: /* @__PURE__ */ le(
|
|
3735
3740
|
"div",
|
|
@@ -3737,7 +3742,7 @@ const Yo = q({
|
|
|
3737
3742
|
onContextMenu: (C) => {
|
|
3738
3743
|
C.preventDefault();
|
|
3739
3744
|
},
|
|
3740
|
-
style:
|
|
3745
|
+
style: _,
|
|
3741
3746
|
className: "board",
|
|
3742
3747
|
children: [
|
|
3743
3748
|
/* @__PURE__ */ T(io, {}),
|