react-sync-board 0.2.0 → 0.3.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/cjs/index.js +377 -378
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +377 -378
- package/dist/esm/index.js.map +1 -1
- package/dist/react-sync-board.min.js +3 -3
- package/dist/react-sync-board.min.js.map +1 -1
- package/package.json +4 -2
package/dist/cjs/index.js
CHANGED
|
@@ -411,77 +411,64 @@ function _nonIterableRest() {
|
|
|
411
411
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
412
412
|
}
|
|
413
413
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
function getAugmentedNamespace(n) {
|
|
417
|
-
if (n.__esModule) return n;
|
|
418
|
-
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
419
|
-
Object.keys(n).forEach(function (k) {
|
|
420
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
421
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
422
|
-
enumerable: true,
|
|
423
|
-
get: function () {
|
|
424
|
-
return n[k];
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
});
|
|
428
|
-
return a;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
var lib = {};
|
|
414
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
415
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
432
416
|
|
|
433
|
-
|
|
417
|
+
if (!it) {
|
|
418
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
419
|
+
if (it) o = it;
|
|
420
|
+
var i = 0;
|
|
434
421
|
|
|
435
|
-
|
|
436
|
-
// optimize the gzip compression for this alphabet.
|
|
437
|
-
var urlAlphabet = 'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW';
|
|
438
|
-
|
|
439
|
-
// This file replaces `index.js` in bundlers like webpack or Rollup,
|
|
440
|
-
|
|
441
|
-
var random = function random(bytes) {
|
|
442
|
-
return crypto.getRandomValues(new Uint8Array(bytes));
|
|
443
|
-
};
|
|
422
|
+
var F = function () {};
|
|
444
423
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
// `-~i => i + 1` if i is an integer
|
|
463
|
-
|
|
464
|
-
var step = -~(1.6 * mask * size / alphabet.length);
|
|
465
|
-
return function () {
|
|
466
|
-
var id = '';
|
|
467
|
-
|
|
468
|
-
while (true) {
|
|
469
|
-
var bytes = getRandom(step); // A compact alternative for `for (var i = 0; i < step; i++)`.
|
|
424
|
+
return {
|
|
425
|
+
s: F,
|
|
426
|
+
n: function () {
|
|
427
|
+
if (i >= o.length) return {
|
|
428
|
+
done: true
|
|
429
|
+
};
|
|
430
|
+
return {
|
|
431
|
+
done: false,
|
|
432
|
+
value: o[i++]
|
|
433
|
+
};
|
|
434
|
+
},
|
|
435
|
+
e: function (e) {
|
|
436
|
+
throw e;
|
|
437
|
+
},
|
|
438
|
+
f: F
|
|
439
|
+
};
|
|
440
|
+
}
|
|
470
441
|
|
|
471
|
-
|
|
442
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
443
|
+
}
|
|
472
444
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
445
|
+
var normalCompletion = true,
|
|
446
|
+
didErr = false,
|
|
447
|
+
err;
|
|
448
|
+
return {
|
|
449
|
+
s: function () {
|
|
450
|
+
it = it.call(o);
|
|
451
|
+
},
|
|
452
|
+
n: function () {
|
|
453
|
+
var step = it.next();
|
|
454
|
+
normalCompletion = step.done;
|
|
455
|
+
return step;
|
|
456
|
+
},
|
|
457
|
+
e: function (e) {
|
|
458
|
+
didErr = true;
|
|
459
|
+
err = e;
|
|
460
|
+
},
|
|
461
|
+
f: function () {
|
|
462
|
+
try {
|
|
463
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
464
|
+
} finally {
|
|
465
|
+
if (didErr) throw err;
|
|
477
466
|
}
|
|
478
467
|
}
|
|
479
468
|
};
|
|
480
|
-
}
|
|
469
|
+
}
|
|
481
470
|
|
|
482
|
-
|
|
483
|
-
return customRandom(alphabet, size, random);
|
|
484
|
-
};
|
|
471
|
+
// This file replaces `index.js` in bundlers like webpack or Rollup,
|
|
485
472
|
|
|
486
473
|
var nanoid = function nanoid() {
|
|
487
474
|
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 21;
|
|
@@ -512,199 +499,6 @@ var nanoid = function nanoid() {
|
|
|
512
499
|
return id;
|
|
513
500
|
};
|
|
514
501
|
|
|
515
|
-
var index_prod = /*#__PURE__*/Object.freeze({
|
|
516
|
-
__proto__: null,
|
|
517
|
-
nanoid: nanoid,
|
|
518
|
-
customAlphabet: customAlphabet,
|
|
519
|
-
customRandom: customRandom,
|
|
520
|
-
urlAlphabet: urlAlphabet,
|
|
521
|
-
random: random
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
var require$$0 = /*@__PURE__*/getAugmentedNamespace(index_prod);
|
|
525
|
-
|
|
526
|
-
Object.defineProperty(server, "__esModule", {
|
|
527
|
-
value: true
|
|
528
|
-
});
|
|
529
|
-
server["default"] = server.handleWire = void 0;
|
|
530
|
-
var _nanoid$1 = require$$0;
|
|
531
|
-
var rooms = {};
|
|
532
|
-
|
|
533
|
-
var handleWire = function handleWire(socket) {
|
|
534
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
535
|
-
_ref$log = _ref.log,
|
|
536
|
-
log = _ref$log === void 0 ? console.log : _ref$log,
|
|
537
|
-
_ref$logPrefix = _ref.logPrefix,
|
|
538
|
-
logPrefix = _ref$logPrefix === void 0 ? '[Wire.io] ' : _ref$logPrefix;
|
|
539
|
-
|
|
540
|
-
socket.on('joinSuperSocket', function (_ref2) {
|
|
541
|
-
var roomName = _ref2.room,
|
|
542
|
-
givenUserId = _ref2.userId;
|
|
543
|
-
socket.join(roomName);
|
|
544
|
-
|
|
545
|
-
if (rooms[roomName] === undefined) {
|
|
546
|
-
rooms[roomName] = {
|
|
547
|
-
users: [],
|
|
548
|
-
rpc: {}
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
var userId = givenUserId || (0, _nanoid$1.nanoid)();
|
|
553
|
-
var isMaster = rooms[roomName].users.length === 0;
|
|
554
|
-
|
|
555
|
-
var promoteMaster = function promoteMaster() {
|
|
556
|
-
isMaster = true;
|
|
557
|
-
socket.emit("".concat(roomName, ".isMaster"));
|
|
558
|
-
};
|
|
559
|
-
|
|
560
|
-
rooms[roomName].users.push({
|
|
561
|
-
userId: userId,
|
|
562
|
-
promoteMaster: promoteMaster,
|
|
563
|
-
isMaster: isMaster
|
|
564
|
-
}); // Publish event to others and self if `self`
|
|
565
|
-
|
|
566
|
-
socket.on("".concat(roomName, ".publish"), function (_ref3) {
|
|
567
|
-
var name = _ref3.name,
|
|
568
|
-
params = _ref3.params,
|
|
569
|
-
self = _ref3.self;
|
|
570
|
-
|
|
571
|
-
if (self) {
|
|
572
|
-
socket.emit("".concat(roomName, ".").concat(name), params);
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
socket.broadcast.to(roomName).emit("".concat(roomName, ".").concat(name), params);
|
|
576
|
-
}); // Register new remote function
|
|
577
|
-
|
|
578
|
-
socket.on("".concat(roomName, ".register"), function (_ref4) {
|
|
579
|
-
var name = _ref4.name;
|
|
580
|
-
|
|
581
|
-
// Define function for the room
|
|
582
|
-
rooms[roomName].rpc[name] = function (_ref5) {
|
|
583
|
-
var callId = _ref5.callId,
|
|
584
|
-
params = _ref5.params;
|
|
585
|
-
return new Promise(function (resolve, reject) {
|
|
586
|
-
if (!socket.connected) {
|
|
587
|
-
// Handle case of disconnected socket
|
|
588
|
-
delete rooms[roomName].rpc[name];
|
|
589
|
-
resolve({
|
|
590
|
-
err: "Function ".concat(name, " is not registered")
|
|
591
|
-
});
|
|
592
|
-
} else {
|
|
593
|
-
// Schedule result
|
|
594
|
-
socket.once("".concat(roomName, ".result.").concat(callId), function (result) {
|
|
595
|
-
resolve(result);
|
|
596
|
-
}); // Call function from client
|
|
597
|
-
|
|
598
|
-
socket.emit("".concat(roomName, ".call.").concat(name), {
|
|
599
|
-
callId: callId,
|
|
600
|
-
params: params
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
};
|
|
605
|
-
|
|
606
|
-
socket.emit("".concat(roomName, ".register.").concat(name));
|
|
607
|
-
});
|
|
608
|
-
socket.on("".concat(roomName, ".unregister"), function (_ref6) {
|
|
609
|
-
var name = _ref6.name;
|
|
610
|
-
delete rooms[roomName].rpc[name];
|
|
611
|
-
socket.emit("".concat(roomName, ".unregister.").concat(name));
|
|
612
|
-
}); // Call function from another client
|
|
613
|
-
|
|
614
|
-
socket.on("".concat(roomName, ".call"), /*#__PURE__*/function () {
|
|
615
|
-
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref7) {
|
|
616
|
-
var name, callId, params, result;
|
|
617
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
618
|
-
while (1) {
|
|
619
|
-
switch (_context.prev = _context.next) {
|
|
620
|
-
case 0:
|
|
621
|
-
name = _ref7.name, callId = _ref7.callId, params = _ref7.params;
|
|
622
|
-
|
|
623
|
-
if (!(rooms[roomName].rpc[name] === undefined)) {
|
|
624
|
-
_context.next = 5;
|
|
625
|
-
break;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
socket.emit("".concat(roomName, ".result.").concat(callId), {
|
|
629
|
-
err: "Function ".concat(name, " is not registered")
|
|
630
|
-
});
|
|
631
|
-
_context.next = 9;
|
|
632
|
-
break;
|
|
633
|
-
|
|
634
|
-
case 5:
|
|
635
|
-
_context.next = 7;
|
|
636
|
-
return rooms[roomName].rpc[name]({
|
|
637
|
-
callId: callId,
|
|
638
|
-
params: params
|
|
639
|
-
});
|
|
640
|
-
|
|
641
|
-
case 7:
|
|
642
|
-
result = _context.sent;
|
|
643
|
-
socket.emit("".concat(roomName, ".result.").concat(callId), result);
|
|
644
|
-
|
|
645
|
-
case 9:
|
|
646
|
-
case "end":
|
|
647
|
-
return _context.stop();
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
}, _callee);
|
|
651
|
-
}));
|
|
652
|
-
|
|
653
|
-
return function (_x) {
|
|
654
|
-
return _ref8.apply(this, arguments);
|
|
655
|
-
};
|
|
656
|
-
}());
|
|
657
|
-
|
|
658
|
-
var onLeave = function onLeave() {
|
|
659
|
-
rooms[roomName].users = rooms[roomName].users.filter(function (_ref9) {
|
|
660
|
-
var uid = _ref9.userId;
|
|
661
|
-
return uid !== userId;
|
|
662
|
-
});
|
|
663
|
-
log("".concat(logPrefix, "User ").concat(userId, " quit room ").concat(roomName, ".").concat(isMaster ? ' Was room master. ' : '', " ").concat(rooms[roomName].users.length, " user(s) left.")); // Promote the first user if master is gone
|
|
664
|
-
|
|
665
|
-
if (rooms[roomName].users.length > 0 && !rooms[roomName].users[0].isMaster) {
|
|
666
|
-
var user = rooms[roomName].users[0];
|
|
667
|
-
user.isMaster = true;
|
|
668
|
-
user.promoteMaster();
|
|
669
|
-
log("".concat(logPrefix, "Promote ").concat(user.userId, " master of room ").concat(roomName));
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
socket.broadcast.to(roomName).emit("".concat(roomName, ".userLeave"), userId);
|
|
673
|
-
};
|
|
674
|
-
|
|
675
|
-
socket.on('disconnect', onLeave);
|
|
676
|
-
socket.once("".concat(roomName, ".leave"), function () {
|
|
677
|
-
socket.removeAllListeners("".concat(roomName, ".register"));
|
|
678
|
-
socket.removeAllListeners("".concat(roomName, ".unregister"));
|
|
679
|
-
socket.removeAllListeners("".concat(roomName, ".call"));
|
|
680
|
-
socket.removeAllListeners("".concat(roomName, ".publish"));
|
|
681
|
-
socket.off('disconnect', onLeave);
|
|
682
|
-
onLeave();
|
|
683
|
-
socket.leave(roomName);
|
|
684
|
-
});
|
|
685
|
-
|
|
686
|
-
if (isMaster) {
|
|
687
|
-
promoteMaster();
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
socket.emit("".concat(roomName, ".roomJoined"), userId);
|
|
691
|
-
socket.broadcast.to(roomName).emit("".concat(roomName, ".userEnter"), userId);
|
|
692
|
-
log("".concat(logPrefix, "User ").concat(userId, " joined room ").concat(roomName, ".").concat(isMaster ? ' Is room master.' : '', " Room has ").concat(rooms[roomName].users.length, " user(s)"));
|
|
693
|
-
});
|
|
694
|
-
};
|
|
695
|
-
|
|
696
|
-
server.handleWire = handleWire;
|
|
697
|
-
var _default$1 = handleWire;
|
|
698
|
-
server["default"] = _default$1;
|
|
699
|
-
|
|
700
|
-
var client = {};
|
|
701
|
-
|
|
702
|
-
Object.defineProperty(client, "__esModule", {
|
|
703
|
-
value: true
|
|
704
|
-
});
|
|
705
|
-
client["default"] = client.joinWire = void 0;
|
|
706
|
-
var _nanoid = require$$0;
|
|
707
|
-
|
|
708
502
|
var Wire = /*#__PURE__*/function () {
|
|
709
503
|
function Wire(socket, room) {
|
|
710
504
|
var _this = this;
|
|
@@ -875,7 +669,7 @@ var Wire = /*#__PURE__*/function () {
|
|
|
875
669
|
var _this4 = this;
|
|
876
670
|
|
|
877
671
|
return new Promise(function (resolve, reject) {
|
|
878
|
-
var callId =
|
|
672
|
+
var callId = nanoid();
|
|
879
673
|
|
|
880
674
|
_this4._socket.once("".concat(_this4.room, ".result.").concat(callId), function (result) {
|
|
881
675
|
if (result.hasOwnProperty('ok')) {
|
|
@@ -959,39 +753,6 @@ var joinWire = function joinWire(_ref3) {
|
|
|
959
753
|
});
|
|
960
754
|
};
|
|
961
755
|
|
|
962
|
-
client.joinWire = joinWire;
|
|
963
|
-
var _default = joinWire;
|
|
964
|
-
client["default"] = _default;
|
|
965
|
-
|
|
966
|
-
(function (exports) {
|
|
967
|
-
|
|
968
|
-
Object.defineProperty(exports, "__esModule", {
|
|
969
|
-
value: true
|
|
970
|
-
});
|
|
971
|
-
Object.defineProperty(exports, "handleWire", {
|
|
972
|
-
enumerable: true,
|
|
973
|
-
get: function get() {
|
|
974
|
-
return _server["default"];
|
|
975
|
-
}
|
|
976
|
-
});
|
|
977
|
-
Object.defineProperty(exports, "joinWire", {
|
|
978
|
-
enumerable: true,
|
|
979
|
-
get: function get() {
|
|
980
|
-
return _client["default"];
|
|
981
|
-
}
|
|
982
|
-
});
|
|
983
|
-
|
|
984
|
-
var _server = _interopRequireDefault(server);
|
|
985
|
-
|
|
986
|
-
var _client = _interopRequireDefault(client);
|
|
987
|
-
|
|
988
|
-
function _interopRequireDefault(obj) {
|
|
989
|
-
return obj && obj.__esModule ? obj : {
|
|
990
|
-
"default": obj
|
|
991
|
-
};
|
|
992
|
-
}
|
|
993
|
-
})(lib);
|
|
994
|
-
|
|
995
756
|
function _extends() {
|
|
996
757
|
_extends = Object.assign || function (target) {
|
|
997
758
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -2320,6 +2081,8 @@ var createCache = function createCache(options) {
|
|
|
2320
2081
|
return cache;
|
|
2321
2082
|
};
|
|
2322
2083
|
|
|
2084
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2085
|
+
|
|
2323
2086
|
var reactIs$1 = {exports: {}};
|
|
2324
2087
|
|
|
2325
2088
|
var reactIs_production_min = {};
|
|
@@ -4093,7 +3856,7 @@ var WireProvider = function WireProvider(_ref) {
|
|
|
4093
3856
|
}
|
|
4094
3857
|
|
|
4095
3858
|
console.log("Try to connect to wire ".concat(room, " on channel ").concat(channel));
|
|
4096
|
-
|
|
3859
|
+
joinWire({
|
|
4097
3860
|
socket: socket,
|
|
4098
3861
|
room: room,
|
|
4099
3862
|
onMaster: function onMaster() {
|
|
@@ -4826,9 +4589,115 @@ var useItemActions = function useItemActions() {
|
|
|
4826
4589
|
};
|
|
4827
4590
|
};
|
|
4828
4591
|
|
|
4592
|
+
var es6 = function equal(a, b) {
|
|
4593
|
+
if (a === b) return true;
|
|
4594
|
+
|
|
4595
|
+
if (a && b && _typeof(a) == 'object' && _typeof(b) == 'object') {
|
|
4596
|
+
if (a.constructor !== b.constructor) return false;
|
|
4597
|
+
var length, i, keys;
|
|
4598
|
+
|
|
4599
|
+
if (Array.isArray(a)) {
|
|
4600
|
+
length = a.length;
|
|
4601
|
+
if (length != b.length) return false;
|
|
4602
|
+
|
|
4603
|
+
for (i = length; i-- !== 0;) {
|
|
4604
|
+
if (!equal(a[i], b[i])) return false;
|
|
4605
|
+
}
|
|
4606
|
+
|
|
4607
|
+
return true;
|
|
4608
|
+
}
|
|
4609
|
+
|
|
4610
|
+
if (a instanceof Map && b instanceof Map) {
|
|
4611
|
+
if (a.size !== b.size) return false;
|
|
4612
|
+
|
|
4613
|
+
var _iterator = _createForOfIteratorHelper(a.entries()),
|
|
4614
|
+
_step;
|
|
4615
|
+
|
|
4616
|
+
try {
|
|
4617
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4618
|
+
i = _step.value;
|
|
4619
|
+
if (!b.has(i[0])) return false;
|
|
4620
|
+
}
|
|
4621
|
+
} catch (err) {
|
|
4622
|
+
_iterator.e(err);
|
|
4623
|
+
} finally {
|
|
4624
|
+
_iterator.f();
|
|
4625
|
+
}
|
|
4626
|
+
|
|
4627
|
+
var _iterator2 = _createForOfIteratorHelper(a.entries()),
|
|
4628
|
+
_step2;
|
|
4629
|
+
|
|
4630
|
+
try {
|
|
4631
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
4632
|
+
i = _step2.value;
|
|
4633
|
+
if (!equal(i[1], b.get(i[0]))) return false;
|
|
4634
|
+
}
|
|
4635
|
+
} catch (err) {
|
|
4636
|
+
_iterator2.e(err);
|
|
4637
|
+
} finally {
|
|
4638
|
+
_iterator2.f();
|
|
4639
|
+
}
|
|
4640
|
+
|
|
4641
|
+
return true;
|
|
4642
|
+
}
|
|
4643
|
+
|
|
4644
|
+
if (a instanceof Set && b instanceof Set) {
|
|
4645
|
+
if (a.size !== b.size) return false;
|
|
4646
|
+
|
|
4647
|
+
var _iterator3 = _createForOfIteratorHelper(a.entries()),
|
|
4648
|
+
_step3;
|
|
4649
|
+
|
|
4650
|
+
try {
|
|
4651
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
4652
|
+
i = _step3.value;
|
|
4653
|
+
if (!b.has(i[0])) return false;
|
|
4654
|
+
}
|
|
4655
|
+
} catch (err) {
|
|
4656
|
+
_iterator3.e(err);
|
|
4657
|
+
} finally {
|
|
4658
|
+
_iterator3.f();
|
|
4659
|
+
}
|
|
4660
|
+
|
|
4661
|
+
return true;
|
|
4662
|
+
}
|
|
4663
|
+
|
|
4664
|
+
if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
|
|
4665
|
+
length = a.length;
|
|
4666
|
+
if (length != b.length) return false;
|
|
4667
|
+
|
|
4668
|
+
for (i = length; i-- !== 0;) {
|
|
4669
|
+
if (a[i] !== b[i]) return false;
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4672
|
+
return true;
|
|
4673
|
+
}
|
|
4674
|
+
|
|
4675
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
4676
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
4677
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
4678
|
+
keys = Object.keys(a);
|
|
4679
|
+
length = keys.length;
|
|
4680
|
+
if (length !== Object.keys(b).length) return false;
|
|
4681
|
+
|
|
4682
|
+
for (i = length; i-- !== 0;) {
|
|
4683
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
4684
|
+
}
|
|
4685
|
+
|
|
4686
|
+
for (i = length; i-- !== 0;) {
|
|
4687
|
+
var key = keys[i];
|
|
4688
|
+
if (!equal(a[key], b[key])) return false;
|
|
4689
|
+
}
|
|
4690
|
+
|
|
4691
|
+
return true;
|
|
4692
|
+
} // true if both NaN, false otherwise
|
|
4693
|
+
|
|
4694
|
+
|
|
4695
|
+
return a !== a && b !== b;
|
|
4696
|
+
};
|
|
4697
|
+
|
|
4829
4698
|
var img = "data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8' standalone='no'%3f%3e%3csvg xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:cc='http://creativecommons.org/ns%23' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns%23' xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd' xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape' version='1.1' x='0px' y='0px' viewBox='0 0 75.601318 94.9' xml:space='preserve' id='svg26' sodipodi:docname='lock.svg' width='75.601318' height='94.900002' inkscape:version='0.92.5 (2060ec1f9f%2c 2020-04-08)'%3e%3cmetadata id='metadata32'%3e%3crdf:RDF%3e%3ccc:Work rdf:about=''%3e%3cdc:format%3eimage/svg%2bxml%3c/dc:format%3e%3cdc:type rdf:resource='http://purl.org/dc/dcmitype/StillImage' /%3e%3cdc:title%3e%3c/dc:title%3e%3c/cc:Work%3e%3c/rdf:RDF%3e%3c/metadata%3e%3cdefs id='defs30' /%3e%3csodipodi:namedview pagecolor='black' bordercolor='%23666666' borderopacity='1' objecttolerance='10' gridtolerance='10' guidetolerance='10' inkscape:pageopacity='0' inkscape:pageshadow='2' inkscape:window-width='1848' inkscape:window-height='1016' id='namedview28' showgrid='false' fit-margin-top='0' fit-margin-left='0' fit-margin-right='0' fit-margin-bottom='0' inkscape:zoom='5.3400704' inkscape:cx='3.2640013' inkscape:cy='45.072152' inkscape:window-x='1512' inkscape:window-y='27' inkscape:window-maximized='1' inkscape:current-layer='g16' /%3e%3cg id='g16' transform='translate(-12.2%2c-2.5)'%3e%3cpath d='M 75.4%2c36.8 H 34.1 V 24.6 c 0%2c-8.8 7.1%2c-15.9 15.9%2c-15.9 8.8%2c0 15.9%2c7.1 15.9%2c15.9 0%2c1.7 1.4%2c3.1 3.1%2c3.1 1.7%2c0 3.1%2c-1.4 3.1%2c-3.1 C 72.1%2c12.4 62.2%2c2.5 50%2c2.5 37.8%2c2.5 27.9%2c12.4 27.9%2c24.6 v 12.2 h -3.3 c -6.9%2c0 -12.4%2c5.6 -12.4%2c12.4 V 85 c 0%2c6.9 5.6%2c12.4 12.4%2c12.4 h 50.8 c 6.9%2c0 12.4%2c-5.6 12.4%2c-12.4 V 49.2 C 87.9%2c42.3 82.3%2c36.8 75.4%2c36.8 Z m 6.2%2c48.3 c 0%2c3.4 -2.8%2c6.2 -6.2%2c6.2 H 24.6 c -3.4%2c0 -6.2%2c-2.8 -6.2%2c-6.2 V 49.2 c 0%2c-3.4 2.8%2c-6.2 6.2%2c-6.2 h 50.8 c 3.4%2c0 6.2%2c2.8 6.2%2c6.2 z' id='path12' inkscape:connector-curvature='0' style='fill:white%3bfill-opacity:1' /%3e%3cpath d='m 59.8%2c57.6 -12.5%2c12.5 -7%2c-7 c -1.2%2c-1.2 -3.2%2c-1.2 -4.4%2c0 -1.2%2c1.2 -1.2%2c3.2 0%2c4.4 l 9.2%2c9.2 c 0.6%2c0.6 1.4%2c0.9 2.2%2c0.9 0.8%2c0 1.6%2c-0.3 2.2%2c-0.9 L 64.2%2c62 c 1.2%2c-1.2 1.2%2c-3.2 0%2c-4.4 -1.2%2c-1.2 -3.2%2c-1.2 -4.4%2c0 z' id='path14' inkscape:connector-curvature='0' style='fill:white%3bfill-opacity:1' /%3e%3c/g%3e%3c/svg%3e";
|
|
4830
4699
|
|
|
4831
|
-
var _excluded$
|
|
4700
|
+
var _excluded$2 = ["type", "rotation", "id", "locked", "layer"],
|
|
4832
4701
|
_excluded2 = ["x", "y", "layer", "moving"],
|
|
4833
4702
|
_excluded3 = ["state"];
|
|
4834
4703
|
|
|
@@ -4838,23 +4707,101 @@ var ItemWrapper = newStyled.div(_templateObject$2 || (_templateObject$2 = _tagge
|
|
|
4838
4707
|
return rotation;
|
|
4839
4708
|
}, img);
|
|
4840
4709
|
|
|
4841
|
-
var
|
|
4842
|
-
var
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4710
|
+
var DefaultErrorComponent = function DefaultErrorComponent(_ref2) {
|
|
4711
|
+
var onReload = _ref2.onReload;
|
|
4712
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4713
|
+
style: {
|
|
4714
|
+
width: "100px",
|
|
4715
|
+
display: "flex",
|
|
4716
|
+
flexDirection: "column",
|
|
4717
|
+
justifyContent: "center",
|
|
4718
|
+
textAlign: "center",
|
|
4719
|
+
color: "red"
|
|
4720
|
+
},
|
|
4721
|
+
className: "syncboard-error-item"
|
|
4722
|
+
}, "Sorry, this item seems broken.", /*#__PURE__*/React__default['default'].createElement("button", {
|
|
4723
|
+
onClick: onReload
|
|
4724
|
+
}, "Reload it"));
|
|
4725
|
+
};
|
|
4726
|
+
/* Error boundary for broken item */
|
|
4727
|
+
|
|
4728
|
+
|
|
4729
|
+
var ItemErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
4730
|
+
_inherits(ItemErrorBoundary, _React$Component);
|
|
4731
|
+
|
|
4732
|
+
var _super = _createSuper(ItemErrorBoundary);
|
|
4733
|
+
|
|
4734
|
+
function ItemErrorBoundary(props) {
|
|
4735
|
+
var _this;
|
|
4736
|
+
|
|
4737
|
+
_classCallCheck(this, ItemErrorBoundary);
|
|
4738
|
+
|
|
4739
|
+
_this = _super.call(this, props);
|
|
4740
|
+
_this.state = {
|
|
4741
|
+
hasError: false,
|
|
4742
|
+
itemId: props.itemId
|
|
4743
|
+
};
|
|
4744
|
+
_this.onReload = _this.onReload.bind(_assertThisInitialized(_this));
|
|
4745
|
+
return _this;
|
|
4746
|
+
}
|
|
4747
|
+
|
|
4748
|
+
_createClass(ItemErrorBoundary, [{
|
|
4749
|
+
key: "componentDidCatch",
|
|
4750
|
+
value: function componentDidCatch(error) {
|
|
4751
|
+
// eslint-disable-next-line no-console
|
|
4752
|
+
console.log("Error for item ".concat(this.state.itemId), error, this.props.state);
|
|
4753
|
+
}
|
|
4754
|
+
}, {
|
|
4755
|
+
key: "onReload",
|
|
4756
|
+
value: function onReload() {
|
|
4757
|
+
this.setState({
|
|
4758
|
+
hasError: false
|
|
4759
|
+
});
|
|
4760
|
+
}
|
|
4761
|
+
}, {
|
|
4762
|
+
key: "render",
|
|
4763
|
+
value: function render() {
|
|
4764
|
+
var ErrorComponent = this.props.ErrorComponent;
|
|
4765
|
+
|
|
4766
|
+
if (this.state.hasError) {
|
|
4767
|
+
return /*#__PURE__*/React__default['default'].createElement(ErrorComponent, {
|
|
4768
|
+
onReload: this.onReload
|
|
4769
|
+
});
|
|
4770
|
+
}
|
|
4771
|
+
|
|
4772
|
+
return this.props.children;
|
|
4773
|
+
}
|
|
4774
|
+
}], [{
|
|
4775
|
+
key: "getDerivedStateFromError",
|
|
4776
|
+
value: function getDerivedStateFromError() {
|
|
4777
|
+
return {
|
|
4778
|
+
hasError: true
|
|
4779
|
+
};
|
|
4780
|
+
}
|
|
4781
|
+
}]);
|
|
4782
|
+
|
|
4783
|
+
return ItemErrorBoundary;
|
|
4784
|
+
}(React__default['default'].Component);
|
|
4785
|
+
|
|
4786
|
+
var Item = function Item(_ref3) {
|
|
4787
|
+
var _itemMap$error;
|
|
4788
|
+
|
|
4789
|
+
var setState = _ref3.setState,
|
|
4790
|
+
_ref3$state = _ref3.state;
|
|
4791
|
+
_ref3$state = _ref3$state === void 0 ? {} : _ref3$state;
|
|
4792
|
+
|
|
4793
|
+
var type = _ref3$state.type,
|
|
4794
|
+
_ref3$state$rotation = _ref3$state.rotation,
|
|
4795
|
+
rotation = _ref3$state$rotation === void 0 ? 0 : _ref3$state$rotation,
|
|
4796
|
+
id = _ref3$state.id,
|
|
4797
|
+
locked = _ref3$state.locked,
|
|
4798
|
+
layer = _ref3$state.layer,
|
|
4799
|
+
rest = _objectWithoutProperties(_ref3$state, _excluded$2),
|
|
4800
|
+
_ref3$animate = _ref3.animate,
|
|
4801
|
+
animate = _ref3$animate === void 0 ? "hvr-pop" : _ref3$animate,
|
|
4802
|
+
isSelected = _ref3.isSelected,
|
|
4803
|
+
itemMap = _ref3.itemMap,
|
|
4804
|
+
unlocked = _ref3.unlocked;
|
|
4858
4805
|
|
|
4859
4806
|
var isMountedRef = React__default['default'].useRef(false);
|
|
4860
4807
|
var animateRef = React__default['default'].useRef(null);
|
|
@@ -4904,10 +4851,15 @@ var Item = function Item(_ref2) {
|
|
|
4904
4851
|
onKeyUp: function onKeyUp(e) {
|
|
4905
4852
|
return e.stopPropagation();
|
|
4906
4853
|
}
|
|
4854
|
+
}, /*#__PURE__*/React__default['default'].createElement(ItemErrorBoundary, {
|
|
4855
|
+
itemId: id,
|
|
4856
|
+
state: rest,
|
|
4857
|
+
setState: updateState,
|
|
4858
|
+
ErrorComponent: (itemMap === null || itemMap === void 0 ? void 0 : (_itemMap$error = itemMap.error) === null || _itemMap$error === void 0 ? void 0 : _itemMap$error.component) || DefaultErrorComponent
|
|
4907
4859
|
}, /*#__PURE__*/React__default['default'].createElement(Component, _extends$1({}, rest, {
|
|
4908
4860
|
id: id,
|
|
4909
4861
|
setState: updateState
|
|
4910
|
-
})), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4862
|
+
}))), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4911
4863
|
className: "corner top-left"
|
|
4912
4864
|
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4913
4865
|
className: "corner top-right"
|
|
@@ -4918,30 +4870,30 @@ var Item = function Item(_ref2) {
|
|
|
4918
4870
|
})));
|
|
4919
4871
|
};
|
|
4920
4872
|
|
|
4921
|
-
var MemoizedItem = /*#__PURE__*/React.memo(Item, function (
|
|
4922
|
-
var prevState =
|
|
4923
|
-
prevSetState =
|
|
4924
|
-
prevIsSelected =
|
|
4925
|
-
prevUnlocked =
|
|
4926
|
-
var nextState =
|
|
4927
|
-
nextSetState =
|
|
4928
|
-
nextIsSelected =
|
|
4929
|
-
nextUnlocked =
|
|
4873
|
+
var MemoizedItem = /*#__PURE__*/React.memo(Item, function (_ref4, _ref5) {
|
|
4874
|
+
var prevState = _ref4.state,
|
|
4875
|
+
prevSetState = _ref4.setState,
|
|
4876
|
+
prevIsSelected = _ref4.isSelected,
|
|
4877
|
+
prevUnlocked = _ref4.unlocked;
|
|
4878
|
+
var nextState = _ref5.state,
|
|
4879
|
+
nextSetState = _ref5.setState,
|
|
4880
|
+
nextIsSelected = _ref5.isSelected,
|
|
4881
|
+
nextUnlocked = _ref5.unlocked;
|
|
4930
4882
|
return prevIsSelected === nextIsSelected && prevUnlocked === nextUnlocked && prevSetState === nextSetState && JSON.stringify(prevState) === JSON.stringify(nextState);
|
|
4931
4883
|
}); // Exclude positionning from memoization
|
|
4932
4884
|
|
|
4933
|
-
var PositionedItem = function PositionedItem(
|
|
4934
|
-
var
|
|
4935
|
-
|
|
4885
|
+
var PositionedItem = function PositionedItem(_ref6) {
|
|
4886
|
+
var _ref6$state = _ref6.state;
|
|
4887
|
+
_ref6$state = _ref6$state === void 0 ? {} : _ref6$state;
|
|
4936
4888
|
|
|
4937
|
-
var
|
|
4938
|
-
x =
|
|
4939
|
-
|
|
4940
|
-
y =
|
|
4941
|
-
layer =
|
|
4942
|
-
moving =
|
|
4943
|
-
stateRest = _objectWithoutProperties(
|
|
4944
|
-
rest = _objectWithoutProperties(
|
|
4889
|
+
var _ref6$state$x = _ref6$state.x,
|
|
4890
|
+
x = _ref6$state$x === void 0 ? 0 : _ref6$state$x,
|
|
4891
|
+
_ref6$state$y = _ref6$state.y,
|
|
4892
|
+
y = _ref6$state$y === void 0 ? 0 : _ref6$state$y,
|
|
4893
|
+
layer = _ref6$state.layer,
|
|
4894
|
+
moving = _ref6$state.moving,
|
|
4895
|
+
stateRest = _objectWithoutProperties(_ref6$state, _excluded2),
|
|
4896
|
+
rest = _objectWithoutProperties(_ref6, _excluded3);
|
|
4945
4897
|
|
|
4946
4898
|
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4947
4899
|
style: {
|
|
@@ -5567,7 +5519,7 @@ var isItemInsideElement = function isItemInsideElement(itemElement, otherElem) {
|
|
|
5567
5519
|
|
|
5568
5520
|
var isMacOS = function isMacOS() {
|
|
5569
5521
|
var userAgent = navigator.userAgent.toLowerCase();
|
|
5570
|
-
return /mac
|
|
5522
|
+
return /mac os ?x 10/.test(userAgent);
|
|
5571
5523
|
}; // From https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
|
|
5572
5524
|
|
|
5573
5525
|
var getScrollLineHeight = function getScrollLineHeight() {
|
|
@@ -6131,7 +6083,7 @@ var Selector = function Selector(_ref) {
|
|
|
6131
6083
|
var stateRef = React__default['default'].useRef({
|
|
6132
6084
|
moving: false
|
|
6133
6085
|
});
|
|
6134
|
-
var config = recoil.useRecoilValue(BoardConfigAtom); // Reset selection on
|
|
6086
|
+
var config = recoil.useRecoilValue(BoardConfigAtom); // Reset selection on board loading
|
|
6135
6087
|
|
|
6136
6088
|
React__default['default'].useEffect(function () {
|
|
6137
6089
|
setSelected(emptySelection);
|
|
@@ -6791,32 +6743,26 @@ function F(t) {
|
|
|
6791
6743
|
return w(t) > .179;
|
|
6792
6744
|
}
|
|
6793
6745
|
|
|
6746
|
+
var _excluded$1 = ["pos"];
|
|
6747
|
+
|
|
6794
6748
|
var _templateObject$1, _templateObject2;
|
|
6795
|
-
var StyledCursor = newStyled.div(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
return "translate(".concat(left, "px, ").concat(top, "px)");
|
|
6799
|
-
});
|
|
6800
|
-
var CursorName = newStyled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n font-weight: bold;\n padding: 0 0.5em;\n border-radius: 2px;\n max-width: 5em;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-left: -0.5em;\n margin-top: 1.7em;\n whitespace: nowrap;\n background-color: ", ";\n"])), function (_ref2) {
|
|
6801
|
-
var textColor = _ref2.textColor;
|
|
6749
|
+
var StyledCursor = newStyled.div(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n align-items: center;\n z-index: 210;\n"])));
|
|
6750
|
+
var CursorName = newStyled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n font-weight: bold;\n padding: 0 0.5em;\n border-radius: 2px;\n max-width: 5em;\n overflow: hidden;\n text-overflow: ellipsis;\n margin-left: -0.5em;\n margin-top: 1.7em;\n whitespace: nowrap;\n background-color: ", ";\n"])), function (_ref) {
|
|
6751
|
+
var textColor = _ref.textColor;
|
|
6802
6752
|
return textColor;
|
|
6803
|
-
}, function (
|
|
6804
|
-
var color =
|
|
6753
|
+
}, function (_ref2) {
|
|
6754
|
+
var color = _ref2.color;
|
|
6805
6755
|
return color;
|
|
6806
6756
|
});
|
|
6807
6757
|
|
|
6808
|
-
var Cursor = function Cursor(
|
|
6809
|
-
var
|
|
6810
|
-
color =
|
|
6811
|
-
|
|
6812
|
-
size =
|
|
6813
|
-
|
|
6814
|
-
text = _ref4.text;
|
|
6758
|
+
var Cursor = function Cursor(_ref3) {
|
|
6759
|
+
var _ref3$color = _ref3.color,
|
|
6760
|
+
color = _ref3$color === void 0 ? "#666" : _ref3$color,
|
|
6761
|
+
_ref3$size = _ref3.size,
|
|
6762
|
+
size = _ref3$size === void 0 ? 40 : _ref3$size,
|
|
6763
|
+
text = _ref3.text;
|
|
6815
6764
|
var textColor = F(color) ? "#222" : "#EEE";
|
|
6816
|
-
return /*#__PURE__*/React__default['default'].createElement(StyledCursor, {
|
|
6817
|
-
top: pos.y - 10,
|
|
6818
|
-
left: pos.x - 5
|
|
6819
|
-
}, /*#__PURE__*/React__default['default'].createElement("svg", {
|
|
6765
|
+
return /*#__PURE__*/React__default['default'].createElement(StyledCursor, null, /*#__PURE__*/React__default['default'].createElement("svg", {
|
|
6820
6766
|
version: "1.1",
|
|
6821
6767
|
id: "Layer_1",
|
|
6822
6768
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -6841,6 +6787,23 @@ var Cursor = function Cursor(_ref4) {
|
|
|
6841
6787
|
}, text));
|
|
6842
6788
|
};
|
|
6843
6789
|
|
|
6790
|
+
var MemoizedCursor = /*#__PURE__*/React__default['default'].memo(Cursor);
|
|
6791
|
+
|
|
6792
|
+
var PositionnedCursor = function PositionnedCursor(_ref4) {
|
|
6793
|
+
var pos = _ref4.pos,
|
|
6794
|
+
rest = _objectWithoutProperties(_ref4, _excluded$1);
|
|
6795
|
+
|
|
6796
|
+
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
6797
|
+
style: {
|
|
6798
|
+
transform: "translate(".concat(pos.x - 5, "px, ").concat(pos.y - 3, "px)"),
|
|
6799
|
+
top: 0,
|
|
6800
|
+
left: 0,
|
|
6801
|
+
zIndex: 210,
|
|
6802
|
+
position: "fixed"
|
|
6803
|
+
}
|
|
6804
|
+
}, /*#__PURE__*/React__default['default'].createElement(MemoizedCursor, rest));
|
|
6805
|
+
};
|
|
6806
|
+
|
|
6844
6807
|
var Cursors = function Cursors(_ref) {
|
|
6845
6808
|
var users = _ref.users;
|
|
6846
6809
|
|
|
@@ -6916,7 +6879,7 @@ var Cursors = function Cursors(_ref) {
|
|
|
6916
6879
|
userId = _ref5[0],
|
|
6917
6880
|
pos = _ref5[1];
|
|
6918
6881
|
|
|
6919
|
-
return /*#__PURE__*/React__default['default'].createElement(
|
|
6882
|
+
return /*#__PURE__*/React__default['default'].createElement(PositionnedCursor, {
|
|
6920
6883
|
key: userId,
|
|
6921
6884
|
pos: pos,
|
|
6922
6885
|
text: usersById[userId].name,
|
|
@@ -7455,7 +7418,12 @@ var PanZoomRotate = function PanZoomRotate(_ref) {
|
|
|
7455
7418
|
|
|
7456
7419
|
var config = recoil.useRecoilValue(BoardConfigAtom);
|
|
7457
7420
|
var setBoardState = recoil.useSetRecoilState(BoardStateAtom);
|
|
7458
|
-
var prevDim = usePrevious(dim);
|
|
7421
|
+
var prevDim = usePrevious(dim);
|
|
7422
|
+
var mouseRef = React__default['default'].useRef({
|
|
7423
|
+
hover: false,
|
|
7424
|
+
x: 0,
|
|
7425
|
+
y: 0
|
|
7426
|
+
}); // Hooks to save/restore position
|
|
7459
7427
|
|
|
7460
7428
|
usePositionNavigator();
|
|
7461
7429
|
|
|
@@ -7490,7 +7458,7 @@ var PanZoomRotate = function PanZoomRotate(_ref) {
|
|
|
7490
7458
|
translateY: prevDimension.translateY + deltaY
|
|
7491
7459
|
});
|
|
7492
7460
|
});
|
|
7493
|
-
}, [scale, setDim]); // Center board on
|
|
7461
|
+
}, [scale, setDim]); // Center board on board loading
|
|
7494
7462
|
|
|
7495
7463
|
React__default['default'].useEffect(function () {
|
|
7496
7464
|
var _boardRef$current$get = boardRef.current.getBoundingClientRect(),
|
|
@@ -7757,9 +7725,11 @@ var PanZoomRotate = function PanZoomRotate(_ref) {
|
|
|
7757
7725
|
e.preventDefault();
|
|
7758
7726
|
|
|
7759
7727
|
case 31:
|
|
7760
|
-
//
|
|
7728
|
+
// Temporary zoom
|
|
7761
7729
|
if (e.key === " " && !e.repeat) {
|
|
7762
|
-
|
|
7730
|
+
if (mouseRef.current.hover) {
|
|
7731
|
+
zoomTo(3, mouseRef.current);
|
|
7732
|
+
}
|
|
7763
7733
|
}
|
|
7764
7734
|
|
|
7765
7735
|
case 32:
|
|
@@ -7779,10 +7749,23 @@ var PanZoomRotate = function PanZoomRotate(_ref) {
|
|
|
7779
7749
|
// Ignore text in Input or Textarea
|
|
7780
7750
|
if (["INPUT", "TEXTAREA"].includes(e.target.tagName)) return; // Zoom out on release
|
|
7781
7751
|
|
|
7782
|
-
if (e.key === " ") {
|
|
7783
|
-
zoomTo(1 / 3);
|
|
7752
|
+
if (e.key === " " && mouseRef.current.hover) {
|
|
7753
|
+
zoomTo(1 / 3, mouseRef.current);
|
|
7784
7754
|
}
|
|
7785
|
-
}, [zoomTo]);
|
|
7755
|
+
}, [zoomTo]); // Save mouse position for temporary zoom
|
|
7756
|
+
|
|
7757
|
+
var onMouseMove = React__default['default'].useCallback(function (e) {
|
|
7758
|
+
var clientX = e.clientX,
|
|
7759
|
+
clientY = e.clientY;
|
|
7760
|
+
mouseRef.current.x = clientX;
|
|
7761
|
+
mouseRef.current.y = clientY;
|
|
7762
|
+
}, []);
|
|
7763
|
+
var onMouseEnter = React__default['default'].useCallback(function () {
|
|
7764
|
+
mouseRef.current.hover = true;
|
|
7765
|
+
}, []);
|
|
7766
|
+
var onMouseLeave = React__default['default'].useCallback(function () {
|
|
7767
|
+
mouseRef.current.hover = false;
|
|
7768
|
+
}, []);
|
|
7786
7769
|
React__default['default'].useEffect(function () {
|
|
7787
7770
|
document.addEventListener("keydown", onKeyDown);
|
|
7788
7771
|
document.addEventListener("keyup", onKeyUp);
|
|
@@ -7805,7 +7788,10 @@ var PanZoomRotate = function PanZoomRotate(_ref) {
|
|
|
7805
7788
|
ref: wrappedRef,
|
|
7806
7789
|
onContextMenu: function onContextMenu(e) {
|
|
7807
7790
|
e.preventDefault();
|
|
7808
|
-
}
|
|
7791
|
+
},
|
|
7792
|
+
onMouseMove: onMouseMove,
|
|
7793
|
+
onMouseEnter: onMouseEnter,
|
|
7794
|
+
onMouseLeave: onMouseLeave
|
|
7809
7795
|
}, children));
|
|
7810
7796
|
};
|
|
7811
7797
|
|
|
@@ -8197,6 +8183,13 @@ var Board = function Board(_ref) {
|
|
|
8197
8183
|
})))))), /*#__PURE__*/React__default['default'].createElement(Selection, null));
|
|
8198
8184
|
};
|
|
8199
8185
|
|
|
8186
|
+
/**
|
|
8187
|
+
* Returns the default actions of an item
|
|
8188
|
+
* @param {object} item to consider
|
|
8189
|
+
* @param {object} itemMap item template map with default actions
|
|
8190
|
+
* @returns An array of default action for this item
|
|
8191
|
+
*/
|
|
8192
|
+
|
|
8200
8193
|
var getDefaultActionsFromItem = function getDefaultActionsFromItem(item, itemMap) {
|
|
8201
8194
|
if (item.type in itemMap) {
|
|
8202
8195
|
var actions = itemMap[item.type].defaultActions;
|
|
@@ -8210,27 +8203,26 @@ var getDefaultActionsFromItem = function getDefaultActionsFromItem(item, itemMap
|
|
|
8210
8203
|
|
|
8211
8204
|
return [];
|
|
8212
8205
|
};
|
|
8206
|
+
/**
|
|
8207
|
+
* Returns actual actions from an item ordered by the configured available
|
|
8208
|
+
* actions. If no action is defined, default actions are returned.
|
|
8209
|
+
* @param {object} item item to use
|
|
8210
|
+
* @param {object} itemMap item template map with available action for this item
|
|
8211
|
+
* @returns the array of actions for this item
|
|
8212
|
+
*/
|
|
8213
8213
|
|
|
8214
|
-
var getAvailableActionsFromItem = function getAvailableActionsFromItem(item, itemMap) {
|
|
8215
|
-
if (item.type in itemMap) {
|
|
8216
|
-
var actions = itemMap[item.type].availableActions;
|
|
8217
|
-
|
|
8218
|
-
if (typeof actions === "function") {
|
|
8219
|
-
return actions(item);
|
|
8220
|
-
}
|
|
8221
|
-
|
|
8222
|
-
return actions;
|
|
8223
|
-
}
|
|
8224
|
-
|
|
8225
|
-
return [];
|
|
8226
|
-
};
|
|
8227
8214
|
|
|
8228
8215
|
var getActionsFromItem = function getActionsFromItem(item, itemMap) {
|
|
8229
8216
|
var _item$actions = item.actions,
|
|
8230
|
-
actions = _item$actions === void 0 ? getDefaultActionsFromItem(item, itemMap) : _item$actions;
|
|
8217
|
+
actions = _item$actions === void 0 ? getDefaultActionsFromItem(item, itemMap) : _item$actions;
|
|
8218
|
+
return actions.map(function (action) {
|
|
8219
|
+
if (typeof action === "string") {
|
|
8220
|
+
return {
|
|
8221
|
+
name: action
|
|
8222
|
+
};
|
|
8223
|
+
}
|
|
8231
8224
|
|
|
8232
|
-
|
|
8233
|
-
return actions.includes(action);
|
|
8225
|
+
return action;
|
|
8234
8226
|
});
|
|
8235
8227
|
};
|
|
8236
8228
|
|
|
@@ -8300,6 +8292,11 @@ var useAvailableActions = function useAvailableActions() {
|
|
|
8300
8292
|
isMountedRef.current = false;
|
|
8301
8293
|
};
|
|
8302
8294
|
}, []);
|
|
8295
|
+
/**
|
|
8296
|
+
* Returns available actions for selected items. An action is kept only if all
|
|
8297
|
+
* items have this exact same action with same parameters.
|
|
8298
|
+
*/
|
|
8299
|
+
|
|
8303
8300
|
var updateAvailableActions = React__default['default'].useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
8304
8301
|
var _yield$getItemListOrS, _yield$getItemListOrS2, selectedItemIds, selectedItemList, allActions;
|
|
8305
8302
|
|
|
@@ -8332,8 +8329,10 @@ var useAvailableActions = function useAvailableActions() {
|
|
|
8332
8329
|
allActions = selectedItemList.reduce(function (acc, item) {
|
|
8333
8330
|
var itemActions = getActionsFromItem(item, itemMap);
|
|
8334
8331
|
return acc.filter(function (value) {
|
|
8335
|
-
return itemActions.
|
|
8336
|
-
|
|
8332
|
+
return itemActions.some(function (itemAction) {
|
|
8333
|
+
return es6(value, itemAction);
|
|
8334
|
+
});
|
|
8335
|
+
});
|
|
8337
8336
|
}, getActionsFromItem(selectedItemList[0], itemMap));
|
|
8338
8337
|
setAvailableActions(allActions);
|
|
8339
8338
|
_context2.next = 14;
|