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/esm/index.js
CHANGED
|
@@ -403,77 +403,64 @@ function _nonIterableRest() {
|
|
|
403
403
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
404
404
|
}
|
|
405
405
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
function getAugmentedNamespace(n) {
|
|
409
|
-
if (n.__esModule) return n;
|
|
410
|
-
var a = Object.defineProperty({}, '__esModule', {value: true});
|
|
411
|
-
Object.keys(n).forEach(function (k) {
|
|
412
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
413
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
414
|
-
enumerable: true,
|
|
415
|
-
get: function () {
|
|
416
|
-
return n[k];
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
});
|
|
420
|
-
return a;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
var lib = {};
|
|
406
|
+
function _createForOfIteratorHelper(o, allowArrayLike) {
|
|
407
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
424
408
|
|
|
425
|
-
|
|
409
|
+
if (!it) {
|
|
410
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
411
|
+
if (it) o = it;
|
|
412
|
+
var i = 0;
|
|
426
413
|
|
|
427
|
-
|
|
428
|
-
// optimize the gzip compression for this alphabet.
|
|
429
|
-
var urlAlphabet = 'ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW';
|
|
430
|
-
|
|
431
|
-
// This file replaces `index.js` in bundlers like webpack or Rollup,
|
|
432
|
-
|
|
433
|
-
var random = function random(bytes) {
|
|
434
|
-
return crypto.getRandomValues(new Uint8Array(bytes));
|
|
435
|
-
};
|
|
414
|
+
var F = function () {};
|
|
436
415
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
// `-~i => i + 1` if i is an integer
|
|
455
|
-
|
|
456
|
-
var step = -~(1.6 * mask * size / alphabet.length);
|
|
457
|
-
return function () {
|
|
458
|
-
var id = '';
|
|
459
|
-
|
|
460
|
-
while (true) {
|
|
461
|
-
var bytes = getRandom(step); // A compact alternative for `for (var i = 0; i < step; i++)`.
|
|
416
|
+
return {
|
|
417
|
+
s: F,
|
|
418
|
+
n: function () {
|
|
419
|
+
if (i >= o.length) return {
|
|
420
|
+
done: true
|
|
421
|
+
};
|
|
422
|
+
return {
|
|
423
|
+
done: false,
|
|
424
|
+
value: o[i++]
|
|
425
|
+
};
|
|
426
|
+
},
|
|
427
|
+
e: function (e) {
|
|
428
|
+
throw e;
|
|
429
|
+
},
|
|
430
|
+
f: F
|
|
431
|
+
};
|
|
432
|
+
}
|
|
462
433
|
|
|
463
|
-
|
|
434
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
435
|
+
}
|
|
464
436
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
437
|
+
var normalCompletion = true,
|
|
438
|
+
didErr = false,
|
|
439
|
+
err;
|
|
440
|
+
return {
|
|
441
|
+
s: function () {
|
|
442
|
+
it = it.call(o);
|
|
443
|
+
},
|
|
444
|
+
n: function () {
|
|
445
|
+
var step = it.next();
|
|
446
|
+
normalCompletion = step.done;
|
|
447
|
+
return step;
|
|
448
|
+
},
|
|
449
|
+
e: function (e) {
|
|
450
|
+
didErr = true;
|
|
451
|
+
err = e;
|
|
452
|
+
},
|
|
453
|
+
f: function () {
|
|
454
|
+
try {
|
|
455
|
+
if (!normalCompletion && it.return != null) it.return();
|
|
456
|
+
} finally {
|
|
457
|
+
if (didErr) throw err;
|
|
469
458
|
}
|
|
470
459
|
}
|
|
471
460
|
};
|
|
472
|
-
}
|
|
461
|
+
}
|
|
473
462
|
|
|
474
|
-
|
|
475
|
-
return customRandom(alphabet, size, random);
|
|
476
|
-
};
|
|
463
|
+
// This file replaces `index.js` in bundlers like webpack or Rollup,
|
|
477
464
|
|
|
478
465
|
var nanoid = function nanoid() {
|
|
479
466
|
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 21;
|
|
@@ -504,199 +491,6 @@ var nanoid = function nanoid() {
|
|
|
504
491
|
return id;
|
|
505
492
|
};
|
|
506
493
|
|
|
507
|
-
var index_prod = /*#__PURE__*/Object.freeze({
|
|
508
|
-
__proto__: null,
|
|
509
|
-
nanoid: nanoid,
|
|
510
|
-
customAlphabet: customAlphabet,
|
|
511
|
-
customRandom: customRandom,
|
|
512
|
-
urlAlphabet: urlAlphabet,
|
|
513
|
-
random: random
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
var require$$0 = /*@__PURE__*/getAugmentedNamespace(index_prod);
|
|
517
|
-
|
|
518
|
-
Object.defineProperty(server, "__esModule", {
|
|
519
|
-
value: true
|
|
520
|
-
});
|
|
521
|
-
server["default"] = server.handleWire = void 0;
|
|
522
|
-
var _nanoid$1 = require$$0;
|
|
523
|
-
var rooms = {};
|
|
524
|
-
|
|
525
|
-
var handleWire = function handleWire(socket) {
|
|
526
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
527
|
-
_ref$log = _ref.log,
|
|
528
|
-
log = _ref$log === void 0 ? console.log : _ref$log,
|
|
529
|
-
_ref$logPrefix = _ref.logPrefix,
|
|
530
|
-
logPrefix = _ref$logPrefix === void 0 ? '[Wire.io] ' : _ref$logPrefix;
|
|
531
|
-
|
|
532
|
-
socket.on('joinSuperSocket', function (_ref2) {
|
|
533
|
-
var roomName = _ref2.room,
|
|
534
|
-
givenUserId = _ref2.userId;
|
|
535
|
-
socket.join(roomName);
|
|
536
|
-
|
|
537
|
-
if (rooms[roomName] === undefined) {
|
|
538
|
-
rooms[roomName] = {
|
|
539
|
-
users: [],
|
|
540
|
-
rpc: {}
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
var userId = givenUserId || (0, _nanoid$1.nanoid)();
|
|
545
|
-
var isMaster = rooms[roomName].users.length === 0;
|
|
546
|
-
|
|
547
|
-
var promoteMaster = function promoteMaster() {
|
|
548
|
-
isMaster = true;
|
|
549
|
-
socket.emit("".concat(roomName, ".isMaster"));
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
rooms[roomName].users.push({
|
|
553
|
-
userId: userId,
|
|
554
|
-
promoteMaster: promoteMaster,
|
|
555
|
-
isMaster: isMaster
|
|
556
|
-
}); // Publish event to others and self if `self`
|
|
557
|
-
|
|
558
|
-
socket.on("".concat(roomName, ".publish"), function (_ref3) {
|
|
559
|
-
var name = _ref3.name,
|
|
560
|
-
params = _ref3.params,
|
|
561
|
-
self = _ref3.self;
|
|
562
|
-
|
|
563
|
-
if (self) {
|
|
564
|
-
socket.emit("".concat(roomName, ".").concat(name), params);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
socket.broadcast.to(roomName).emit("".concat(roomName, ".").concat(name), params);
|
|
568
|
-
}); // Register new remote function
|
|
569
|
-
|
|
570
|
-
socket.on("".concat(roomName, ".register"), function (_ref4) {
|
|
571
|
-
var name = _ref4.name;
|
|
572
|
-
|
|
573
|
-
// Define function for the room
|
|
574
|
-
rooms[roomName].rpc[name] = function (_ref5) {
|
|
575
|
-
var callId = _ref5.callId,
|
|
576
|
-
params = _ref5.params;
|
|
577
|
-
return new Promise(function (resolve, reject) {
|
|
578
|
-
if (!socket.connected) {
|
|
579
|
-
// Handle case of disconnected socket
|
|
580
|
-
delete rooms[roomName].rpc[name];
|
|
581
|
-
resolve({
|
|
582
|
-
err: "Function ".concat(name, " is not registered")
|
|
583
|
-
});
|
|
584
|
-
} else {
|
|
585
|
-
// Schedule result
|
|
586
|
-
socket.once("".concat(roomName, ".result.").concat(callId), function (result) {
|
|
587
|
-
resolve(result);
|
|
588
|
-
}); // Call function from client
|
|
589
|
-
|
|
590
|
-
socket.emit("".concat(roomName, ".call.").concat(name), {
|
|
591
|
-
callId: callId,
|
|
592
|
-
params: params
|
|
593
|
-
});
|
|
594
|
-
}
|
|
595
|
-
});
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
socket.emit("".concat(roomName, ".register.").concat(name));
|
|
599
|
-
});
|
|
600
|
-
socket.on("".concat(roomName, ".unregister"), function (_ref6) {
|
|
601
|
-
var name = _ref6.name;
|
|
602
|
-
delete rooms[roomName].rpc[name];
|
|
603
|
-
socket.emit("".concat(roomName, ".unregister.").concat(name));
|
|
604
|
-
}); // Call function from another client
|
|
605
|
-
|
|
606
|
-
socket.on("".concat(roomName, ".call"), /*#__PURE__*/function () {
|
|
607
|
-
var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref7) {
|
|
608
|
-
var name, callId, params, result;
|
|
609
|
-
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
610
|
-
while (1) {
|
|
611
|
-
switch (_context.prev = _context.next) {
|
|
612
|
-
case 0:
|
|
613
|
-
name = _ref7.name, callId = _ref7.callId, params = _ref7.params;
|
|
614
|
-
|
|
615
|
-
if (!(rooms[roomName].rpc[name] === undefined)) {
|
|
616
|
-
_context.next = 5;
|
|
617
|
-
break;
|
|
618
|
-
}
|
|
619
|
-
|
|
620
|
-
socket.emit("".concat(roomName, ".result.").concat(callId), {
|
|
621
|
-
err: "Function ".concat(name, " is not registered")
|
|
622
|
-
});
|
|
623
|
-
_context.next = 9;
|
|
624
|
-
break;
|
|
625
|
-
|
|
626
|
-
case 5:
|
|
627
|
-
_context.next = 7;
|
|
628
|
-
return rooms[roomName].rpc[name]({
|
|
629
|
-
callId: callId,
|
|
630
|
-
params: params
|
|
631
|
-
});
|
|
632
|
-
|
|
633
|
-
case 7:
|
|
634
|
-
result = _context.sent;
|
|
635
|
-
socket.emit("".concat(roomName, ".result.").concat(callId), result);
|
|
636
|
-
|
|
637
|
-
case 9:
|
|
638
|
-
case "end":
|
|
639
|
-
return _context.stop();
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
}, _callee);
|
|
643
|
-
}));
|
|
644
|
-
|
|
645
|
-
return function (_x) {
|
|
646
|
-
return _ref8.apply(this, arguments);
|
|
647
|
-
};
|
|
648
|
-
}());
|
|
649
|
-
|
|
650
|
-
var onLeave = function onLeave() {
|
|
651
|
-
rooms[roomName].users = rooms[roomName].users.filter(function (_ref9) {
|
|
652
|
-
var uid = _ref9.userId;
|
|
653
|
-
return uid !== userId;
|
|
654
|
-
});
|
|
655
|
-
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
|
|
656
|
-
|
|
657
|
-
if (rooms[roomName].users.length > 0 && !rooms[roomName].users[0].isMaster) {
|
|
658
|
-
var user = rooms[roomName].users[0];
|
|
659
|
-
user.isMaster = true;
|
|
660
|
-
user.promoteMaster();
|
|
661
|
-
log("".concat(logPrefix, "Promote ").concat(user.userId, " master of room ").concat(roomName));
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
socket.broadcast.to(roomName).emit("".concat(roomName, ".userLeave"), userId);
|
|
665
|
-
};
|
|
666
|
-
|
|
667
|
-
socket.on('disconnect', onLeave);
|
|
668
|
-
socket.once("".concat(roomName, ".leave"), function () {
|
|
669
|
-
socket.removeAllListeners("".concat(roomName, ".register"));
|
|
670
|
-
socket.removeAllListeners("".concat(roomName, ".unregister"));
|
|
671
|
-
socket.removeAllListeners("".concat(roomName, ".call"));
|
|
672
|
-
socket.removeAllListeners("".concat(roomName, ".publish"));
|
|
673
|
-
socket.off('disconnect', onLeave);
|
|
674
|
-
onLeave();
|
|
675
|
-
socket.leave(roomName);
|
|
676
|
-
});
|
|
677
|
-
|
|
678
|
-
if (isMaster) {
|
|
679
|
-
promoteMaster();
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
socket.emit("".concat(roomName, ".roomJoined"), userId);
|
|
683
|
-
socket.broadcast.to(roomName).emit("".concat(roomName, ".userEnter"), userId);
|
|
684
|
-
log("".concat(logPrefix, "User ").concat(userId, " joined room ").concat(roomName, ".").concat(isMaster ? ' Is room master.' : '', " Room has ").concat(rooms[roomName].users.length, " user(s)"));
|
|
685
|
-
});
|
|
686
|
-
};
|
|
687
|
-
|
|
688
|
-
server.handleWire = handleWire;
|
|
689
|
-
var _default$1 = handleWire;
|
|
690
|
-
server["default"] = _default$1;
|
|
691
|
-
|
|
692
|
-
var client = {};
|
|
693
|
-
|
|
694
|
-
Object.defineProperty(client, "__esModule", {
|
|
695
|
-
value: true
|
|
696
|
-
});
|
|
697
|
-
client["default"] = client.joinWire = void 0;
|
|
698
|
-
var _nanoid = require$$0;
|
|
699
|
-
|
|
700
494
|
var Wire = /*#__PURE__*/function () {
|
|
701
495
|
function Wire(socket, room) {
|
|
702
496
|
var _this = this;
|
|
@@ -867,7 +661,7 @@ var Wire = /*#__PURE__*/function () {
|
|
|
867
661
|
var _this4 = this;
|
|
868
662
|
|
|
869
663
|
return new Promise(function (resolve, reject) {
|
|
870
|
-
var callId =
|
|
664
|
+
var callId = nanoid();
|
|
871
665
|
|
|
872
666
|
_this4._socket.once("".concat(_this4.room, ".result.").concat(callId), function (result) {
|
|
873
667
|
if (result.hasOwnProperty('ok')) {
|
|
@@ -951,39 +745,6 @@ var joinWire = function joinWire(_ref3) {
|
|
|
951
745
|
});
|
|
952
746
|
};
|
|
953
747
|
|
|
954
|
-
client.joinWire = joinWire;
|
|
955
|
-
var _default = joinWire;
|
|
956
|
-
client["default"] = _default;
|
|
957
|
-
|
|
958
|
-
(function (exports) {
|
|
959
|
-
|
|
960
|
-
Object.defineProperty(exports, "__esModule", {
|
|
961
|
-
value: true
|
|
962
|
-
});
|
|
963
|
-
Object.defineProperty(exports, "handleWire", {
|
|
964
|
-
enumerable: true,
|
|
965
|
-
get: function get() {
|
|
966
|
-
return _server["default"];
|
|
967
|
-
}
|
|
968
|
-
});
|
|
969
|
-
Object.defineProperty(exports, "joinWire", {
|
|
970
|
-
enumerable: true,
|
|
971
|
-
get: function get() {
|
|
972
|
-
return _client["default"];
|
|
973
|
-
}
|
|
974
|
-
});
|
|
975
|
-
|
|
976
|
-
var _server = _interopRequireDefault(server);
|
|
977
|
-
|
|
978
|
-
var _client = _interopRequireDefault(client);
|
|
979
|
-
|
|
980
|
-
function _interopRequireDefault(obj) {
|
|
981
|
-
return obj && obj.__esModule ? obj : {
|
|
982
|
-
"default": obj
|
|
983
|
-
};
|
|
984
|
-
}
|
|
985
|
-
})(lib);
|
|
986
|
-
|
|
987
748
|
function _extends() {
|
|
988
749
|
_extends = Object.assign || function (target) {
|
|
989
750
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -2312,6 +2073,8 @@ var createCache = function createCache(options) {
|
|
|
2312
2073
|
return cache;
|
|
2313
2074
|
};
|
|
2314
2075
|
|
|
2076
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2077
|
+
|
|
2315
2078
|
var reactIs$1 = {exports: {}};
|
|
2316
2079
|
|
|
2317
2080
|
var reactIs_production_min = {};
|
|
@@ -4085,7 +3848,7 @@ var WireProvider = function WireProvider(_ref) {
|
|
|
4085
3848
|
}
|
|
4086
3849
|
|
|
4087
3850
|
console.log("Try to connect to wire ".concat(room, " on channel ").concat(channel));
|
|
4088
|
-
|
|
3851
|
+
joinWire({
|
|
4089
3852
|
socket: socket,
|
|
4090
3853
|
room: room,
|
|
4091
3854
|
onMaster: function onMaster() {
|
|
@@ -4818,9 +4581,115 @@ var useItemActions = function useItemActions() {
|
|
|
4818
4581
|
};
|
|
4819
4582
|
};
|
|
4820
4583
|
|
|
4584
|
+
var es6 = function equal(a, b) {
|
|
4585
|
+
if (a === b) return true;
|
|
4586
|
+
|
|
4587
|
+
if (a && b && _typeof(a) == 'object' && _typeof(b) == 'object') {
|
|
4588
|
+
if (a.constructor !== b.constructor) return false;
|
|
4589
|
+
var length, i, keys;
|
|
4590
|
+
|
|
4591
|
+
if (Array.isArray(a)) {
|
|
4592
|
+
length = a.length;
|
|
4593
|
+
if (length != b.length) return false;
|
|
4594
|
+
|
|
4595
|
+
for (i = length; i-- !== 0;) {
|
|
4596
|
+
if (!equal(a[i], b[i])) return false;
|
|
4597
|
+
}
|
|
4598
|
+
|
|
4599
|
+
return true;
|
|
4600
|
+
}
|
|
4601
|
+
|
|
4602
|
+
if (a instanceof Map && b instanceof Map) {
|
|
4603
|
+
if (a.size !== b.size) return false;
|
|
4604
|
+
|
|
4605
|
+
var _iterator = _createForOfIteratorHelper(a.entries()),
|
|
4606
|
+
_step;
|
|
4607
|
+
|
|
4608
|
+
try {
|
|
4609
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
4610
|
+
i = _step.value;
|
|
4611
|
+
if (!b.has(i[0])) return false;
|
|
4612
|
+
}
|
|
4613
|
+
} catch (err) {
|
|
4614
|
+
_iterator.e(err);
|
|
4615
|
+
} finally {
|
|
4616
|
+
_iterator.f();
|
|
4617
|
+
}
|
|
4618
|
+
|
|
4619
|
+
var _iterator2 = _createForOfIteratorHelper(a.entries()),
|
|
4620
|
+
_step2;
|
|
4621
|
+
|
|
4622
|
+
try {
|
|
4623
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
4624
|
+
i = _step2.value;
|
|
4625
|
+
if (!equal(i[1], b.get(i[0]))) return false;
|
|
4626
|
+
}
|
|
4627
|
+
} catch (err) {
|
|
4628
|
+
_iterator2.e(err);
|
|
4629
|
+
} finally {
|
|
4630
|
+
_iterator2.f();
|
|
4631
|
+
}
|
|
4632
|
+
|
|
4633
|
+
return true;
|
|
4634
|
+
}
|
|
4635
|
+
|
|
4636
|
+
if (a instanceof Set && b instanceof Set) {
|
|
4637
|
+
if (a.size !== b.size) return false;
|
|
4638
|
+
|
|
4639
|
+
var _iterator3 = _createForOfIteratorHelper(a.entries()),
|
|
4640
|
+
_step3;
|
|
4641
|
+
|
|
4642
|
+
try {
|
|
4643
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
4644
|
+
i = _step3.value;
|
|
4645
|
+
if (!b.has(i[0])) return false;
|
|
4646
|
+
}
|
|
4647
|
+
} catch (err) {
|
|
4648
|
+
_iterator3.e(err);
|
|
4649
|
+
} finally {
|
|
4650
|
+
_iterator3.f();
|
|
4651
|
+
}
|
|
4652
|
+
|
|
4653
|
+
return true;
|
|
4654
|
+
}
|
|
4655
|
+
|
|
4656
|
+
if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
|
|
4657
|
+
length = a.length;
|
|
4658
|
+
if (length != b.length) return false;
|
|
4659
|
+
|
|
4660
|
+
for (i = length; i-- !== 0;) {
|
|
4661
|
+
if (a[i] !== b[i]) return false;
|
|
4662
|
+
}
|
|
4663
|
+
|
|
4664
|
+
return true;
|
|
4665
|
+
}
|
|
4666
|
+
|
|
4667
|
+
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
4668
|
+
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
4669
|
+
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
4670
|
+
keys = Object.keys(a);
|
|
4671
|
+
length = keys.length;
|
|
4672
|
+
if (length !== Object.keys(b).length) return false;
|
|
4673
|
+
|
|
4674
|
+
for (i = length; i-- !== 0;) {
|
|
4675
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
4676
|
+
}
|
|
4677
|
+
|
|
4678
|
+
for (i = length; i-- !== 0;) {
|
|
4679
|
+
var key = keys[i];
|
|
4680
|
+
if (!equal(a[key], b[key])) return false;
|
|
4681
|
+
}
|
|
4682
|
+
|
|
4683
|
+
return true;
|
|
4684
|
+
} // true if both NaN, false otherwise
|
|
4685
|
+
|
|
4686
|
+
|
|
4687
|
+
return a !== a && b !== b;
|
|
4688
|
+
};
|
|
4689
|
+
|
|
4821
4690
|
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";
|
|
4822
4691
|
|
|
4823
|
-
var _excluded$
|
|
4692
|
+
var _excluded$2 = ["type", "rotation", "id", "locked", "layer"],
|
|
4824
4693
|
_excluded2 = ["x", "y", "layer", "moving"],
|
|
4825
4694
|
_excluded3 = ["state"];
|
|
4826
4695
|
|
|
@@ -4830,23 +4699,101 @@ var ItemWrapper = newStyled.div(_templateObject$2 || (_templateObject$2 = _tagge
|
|
|
4830
4699
|
return rotation;
|
|
4831
4700
|
}, img);
|
|
4832
4701
|
|
|
4833
|
-
var
|
|
4834
|
-
var
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4702
|
+
var DefaultErrorComponent = function DefaultErrorComponent(_ref2) {
|
|
4703
|
+
var onReload = _ref2.onReload;
|
|
4704
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
4705
|
+
style: {
|
|
4706
|
+
width: "100px",
|
|
4707
|
+
display: "flex",
|
|
4708
|
+
flexDirection: "column",
|
|
4709
|
+
justifyContent: "center",
|
|
4710
|
+
textAlign: "center",
|
|
4711
|
+
color: "red"
|
|
4712
|
+
},
|
|
4713
|
+
className: "syncboard-error-item"
|
|
4714
|
+
}, "Sorry, this item seems broken.", /*#__PURE__*/React.createElement("button", {
|
|
4715
|
+
onClick: onReload
|
|
4716
|
+
}, "Reload it"));
|
|
4717
|
+
};
|
|
4718
|
+
/* Error boundary for broken item */
|
|
4719
|
+
|
|
4720
|
+
|
|
4721
|
+
var ItemErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
4722
|
+
_inherits(ItemErrorBoundary, _React$Component);
|
|
4723
|
+
|
|
4724
|
+
var _super = _createSuper(ItemErrorBoundary);
|
|
4725
|
+
|
|
4726
|
+
function ItemErrorBoundary(props) {
|
|
4727
|
+
var _this;
|
|
4728
|
+
|
|
4729
|
+
_classCallCheck(this, ItemErrorBoundary);
|
|
4730
|
+
|
|
4731
|
+
_this = _super.call(this, props);
|
|
4732
|
+
_this.state = {
|
|
4733
|
+
hasError: false,
|
|
4734
|
+
itemId: props.itemId
|
|
4735
|
+
};
|
|
4736
|
+
_this.onReload = _this.onReload.bind(_assertThisInitialized(_this));
|
|
4737
|
+
return _this;
|
|
4738
|
+
}
|
|
4739
|
+
|
|
4740
|
+
_createClass(ItemErrorBoundary, [{
|
|
4741
|
+
key: "componentDidCatch",
|
|
4742
|
+
value: function componentDidCatch(error) {
|
|
4743
|
+
// eslint-disable-next-line no-console
|
|
4744
|
+
console.log("Error for item ".concat(this.state.itemId), error, this.props.state);
|
|
4745
|
+
}
|
|
4746
|
+
}, {
|
|
4747
|
+
key: "onReload",
|
|
4748
|
+
value: function onReload() {
|
|
4749
|
+
this.setState({
|
|
4750
|
+
hasError: false
|
|
4751
|
+
});
|
|
4752
|
+
}
|
|
4753
|
+
}, {
|
|
4754
|
+
key: "render",
|
|
4755
|
+
value: function render() {
|
|
4756
|
+
var ErrorComponent = this.props.ErrorComponent;
|
|
4757
|
+
|
|
4758
|
+
if (this.state.hasError) {
|
|
4759
|
+
return /*#__PURE__*/React.createElement(ErrorComponent, {
|
|
4760
|
+
onReload: this.onReload
|
|
4761
|
+
});
|
|
4762
|
+
}
|
|
4763
|
+
|
|
4764
|
+
return this.props.children;
|
|
4765
|
+
}
|
|
4766
|
+
}], [{
|
|
4767
|
+
key: "getDerivedStateFromError",
|
|
4768
|
+
value: function getDerivedStateFromError() {
|
|
4769
|
+
return {
|
|
4770
|
+
hasError: true
|
|
4771
|
+
};
|
|
4772
|
+
}
|
|
4773
|
+
}]);
|
|
4774
|
+
|
|
4775
|
+
return ItemErrorBoundary;
|
|
4776
|
+
}(React.Component);
|
|
4777
|
+
|
|
4778
|
+
var Item = function Item(_ref3) {
|
|
4779
|
+
var _itemMap$error;
|
|
4780
|
+
|
|
4781
|
+
var setState = _ref3.setState,
|
|
4782
|
+
_ref3$state = _ref3.state;
|
|
4783
|
+
_ref3$state = _ref3$state === void 0 ? {} : _ref3$state;
|
|
4784
|
+
|
|
4785
|
+
var type = _ref3$state.type,
|
|
4786
|
+
_ref3$state$rotation = _ref3$state.rotation,
|
|
4787
|
+
rotation = _ref3$state$rotation === void 0 ? 0 : _ref3$state$rotation,
|
|
4788
|
+
id = _ref3$state.id,
|
|
4789
|
+
locked = _ref3$state.locked,
|
|
4790
|
+
layer = _ref3$state.layer,
|
|
4791
|
+
rest = _objectWithoutProperties(_ref3$state, _excluded$2),
|
|
4792
|
+
_ref3$animate = _ref3.animate,
|
|
4793
|
+
animate = _ref3$animate === void 0 ? "hvr-pop" : _ref3$animate,
|
|
4794
|
+
isSelected = _ref3.isSelected,
|
|
4795
|
+
itemMap = _ref3.itemMap,
|
|
4796
|
+
unlocked = _ref3.unlocked;
|
|
4850
4797
|
|
|
4851
4798
|
var isMountedRef = React.useRef(false);
|
|
4852
4799
|
var animateRef = React.useRef(null);
|
|
@@ -4896,10 +4843,15 @@ var Item = function Item(_ref2) {
|
|
|
4896
4843
|
onKeyUp: function onKeyUp(e) {
|
|
4897
4844
|
return e.stopPropagation();
|
|
4898
4845
|
}
|
|
4846
|
+
}, /*#__PURE__*/React.createElement(ItemErrorBoundary, {
|
|
4847
|
+
itemId: id,
|
|
4848
|
+
state: rest,
|
|
4849
|
+
setState: updateState,
|
|
4850
|
+
ErrorComponent: (itemMap === null || itemMap === void 0 ? void 0 : (_itemMap$error = itemMap.error) === null || _itemMap$error === void 0 ? void 0 : _itemMap$error.component) || DefaultErrorComponent
|
|
4899
4851
|
}, /*#__PURE__*/React.createElement(Component, _extends$1({}, rest, {
|
|
4900
4852
|
id: id,
|
|
4901
4853
|
setState: updateState
|
|
4902
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
4854
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
4903
4855
|
className: "corner top-left"
|
|
4904
4856
|
}), /*#__PURE__*/React.createElement("div", {
|
|
4905
4857
|
className: "corner top-right"
|
|
@@ -4910,30 +4862,30 @@ var Item = function Item(_ref2) {
|
|
|
4910
4862
|
})));
|
|
4911
4863
|
};
|
|
4912
4864
|
|
|
4913
|
-
var MemoizedItem = /*#__PURE__*/memo(Item, function (
|
|
4914
|
-
var prevState =
|
|
4915
|
-
prevSetState =
|
|
4916
|
-
prevIsSelected =
|
|
4917
|
-
prevUnlocked =
|
|
4918
|
-
var nextState =
|
|
4919
|
-
nextSetState =
|
|
4920
|
-
nextIsSelected =
|
|
4921
|
-
nextUnlocked =
|
|
4865
|
+
var MemoizedItem = /*#__PURE__*/memo(Item, function (_ref4, _ref5) {
|
|
4866
|
+
var prevState = _ref4.state,
|
|
4867
|
+
prevSetState = _ref4.setState,
|
|
4868
|
+
prevIsSelected = _ref4.isSelected,
|
|
4869
|
+
prevUnlocked = _ref4.unlocked;
|
|
4870
|
+
var nextState = _ref5.state,
|
|
4871
|
+
nextSetState = _ref5.setState,
|
|
4872
|
+
nextIsSelected = _ref5.isSelected,
|
|
4873
|
+
nextUnlocked = _ref5.unlocked;
|
|
4922
4874
|
return prevIsSelected === nextIsSelected && prevUnlocked === nextUnlocked && prevSetState === nextSetState && JSON.stringify(prevState) === JSON.stringify(nextState);
|
|
4923
4875
|
}); // Exclude positionning from memoization
|
|
4924
4876
|
|
|
4925
|
-
var PositionedItem = function PositionedItem(
|
|
4926
|
-
var
|
|
4927
|
-
|
|
4877
|
+
var PositionedItem = function PositionedItem(_ref6) {
|
|
4878
|
+
var _ref6$state = _ref6.state;
|
|
4879
|
+
_ref6$state = _ref6$state === void 0 ? {} : _ref6$state;
|
|
4928
4880
|
|
|
4929
|
-
var
|
|
4930
|
-
x =
|
|
4931
|
-
|
|
4932
|
-
y =
|
|
4933
|
-
layer =
|
|
4934
|
-
moving =
|
|
4935
|
-
stateRest = _objectWithoutProperties(
|
|
4936
|
-
rest = _objectWithoutProperties(
|
|
4881
|
+
var _ref6$state$x = _ref6$state.x,
|
|
4882
|
+
x = _ref6$state$x === void 0 ? 0 : _ref6$state$x,
|
|
4883
|
+
_ref6$state$y = _ref6$state.y,
|
|
4884
|
+
y = _ref6$state$y === void 0 ? 0 : _ref6$state$y,
|
|
4885
|
+
layer = _ref6$state.layer,
|
|
4886
|
+
moving = _ref6$state.moving,
|
|
4887
|
+
stateRest = _objectWithoutProperties(_ref6$state, _excluded2),
|
|
4888
|
+
rest = _objectWithoutProperties(_ref6, _excluded3);
|
|
4937
4889
|
|
|
4938
4890
|
return /*#__PURE__*/React.createElement("div", {
|
|
4939
4891
|
style: {
|
|
@@ -5559,7 +5511,7 @@ var isItemInsideElement = function isItemInsideElement(itemElement, otherElem) {
|
|
|
5559
5511
|
|
|
5560
5512
|
var isMacOS = function isMacOS() {
|
|
5561
5513
|
var userAgent = navigator.userAgent.toLowerCase();
|
|
5562
|
-
return /mac
|
|
5514
|
+
return /mac os ?x 10/.test(userAgent);
|
|
5563
5515
|
}; // From https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
|
|
5564
5516
|
|
|
5565
5517
|
var getScrollLineHeight = function getScrollLineHeight() {
|
|
@@ -6123,7 +6075,7 @@ var Selector = function Selector(_ref) {
|
|
|
6123
6075
|
var stateRef = React.useRef({
|
|
6124
6076
|
moving: false
|
|
6125
6077
|
});
|
|
6126
|
-
var config = useRecoilValue(BoardConfigAtom); // Reset selection on
|
|
6078
|
+
var config = useRecoilValue(BoardConfigAtom); // Reset selection on board loading
|
|
6127
6079
|
|
|
6128
6080
|
React.useEffect(function () {
|
|
6129
6081
|
setSelected(emptySelection);
|
|
@@ -6783,32 +6735,26 @@ function F(t) {
|
|
|
6783
6735
|
return w(t) > .179;
|
|
6784
6736
|
}
|
|
6785
6737
|
|
|
6738
|
+
var _excluded$1 = ["pos"];
|
|
6739
|
+
|
|
6786
6740
|
var _templateObject$1, _templateObject2;
|
|
6787
|
-
var StyledCursor = newStyled.div(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
return "translate(".concat(left, "px, ").concat(top, "px)");
|
|
6791
|
-
});
|
|
6792
|
-
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) {
|
|
6793
|
-
var textColor = _ref2.textColor;
|
|
6741
|
+
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"])));
|
|
6742
|
+
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) {
|
|
6743
|
+
var textColor = _ref.textColor;
|
|
6794
6744
|
return textColor;
|
|
6795
|
-
}, function (
|
|
6796
|
-
var color =
|
|
6745
|
+
}, function (_ref2) {
|
|
6746
|
+
var color = _ref2.color;
|
|
6797
6747
|
return color;
|
|
6798
6748
|
});
|
|
6799
6749
|
|
|
6800
|
-
var Cursor = function Cursor(
|
|
6801
|
-
var
|
|
6802
|
-
color =
|
|
6803
|
-
|
|
6804
|
-
size =
|
|
6805
|
-
|
|
6806
|
-
text = _ref4.text;
|
|
6750
|
+
var Cursor = function Cursor(_ref3) {
|
|
6751
|
+
var _ref3$color = _ref3.color,
|
|
6752
|
+
color = _ref3$color === void 0 ? "#666" : _ref3$color,
|
|
6753
|
+
_ref3$size = _ref3.size,
|
|
6754
|
+
size = _ref3$size === void 0 ? 40 : _ref3$size,
|
|
6755
|
+
text = _ref3.text;
|
|
6807
6756
|
var textColor = F(color) ? "#222" : "#EEE";
|
|
6808
|
-
return /*#__PURE__*/React.createElement(StyledCursor, {
|
|
6809
|
-
top: pos.y - 10,
|
|
6810
|
-
left: pos.x - 5
|
|
6811
|
-
}, /*#__PURE__*/React.createElement("svg", {
|
|
6757
|
+
return /*#__PURE__*/React.createElement(StyledCursor, null, /*#__PURE__*/React.createElement("svg", {
|
|
6812
6758
|
version: "1.1",
|
|
6813
6759
|
id: "Layer_1",
|
|
6814
6760
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -6833,6 +6779,23 @@ var Cursor = function Cursor(_ref4) {
|
|
|
6833
6779
|
}, text));
|
|
6834
6780
|
};
|
|
6835
6781
|
|
|
6782
|
+
var MemoizedCursor = /*#__PURE__*/React.memo(Cursor);
|
|
6783
|
+
|
|
6784
|
+
var PositionnedCursor = function PositionnedCursor(_ref4) {
|
|
6785
|
+
var pos = _ref4.pos,
|
|
6786
|
+
rest = _objectWithoutProperties(_ref4, _excluded$1);
|
|
6787
|
+
|
|
6788
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
6789
|
+
style: {
|
|
6790
|
+
transform: "translate(".concat(pos.x - 5, "px, ").concat(pos.y - 3, "px)"),
|
|
6791
|
+
top: 0,
|
|
6792
|
+
left: 0,
|
|
6793
|
+
zIndex: 210,
|
|
6794
|
+
position: "fixed"
|
|
6795
|
+
}
|
|
6796
|
+
}, /*#__PURE__*/React.createElement(MemoizedCursor, rest));
|
|
6797
|
+
};
|
|
6798
|
+
|
|
6836
6799
|
var Cursors = function Cursors(_ref) {
|
|
6837
6800
|
var users = _ref.users;
|
|
6838
6801
|
|
|
@@ -6908,7 +6871,7 @@ var Cursors = function Cursors(_ref) {
|
|
|
6908
6871
|
userId = _ref5[0],
|
|
6909
6872
|
pos = _ref5[1];
|
|
6910
6873
|
|
|
6911
|
-
return /*#__PURE__*/React.createElement(
|
|
6874
|
+
return /*#__PURE__*/React.createElement(PositionnedCursor, {
|
|
6912
6875
|
key: userId,
|
|
6913
6876
|
pos: pos,
|
|
6914
6877
|
text: usersById[userId].name,
|
|
@@ -7447,7 +7410,12 @@ var PanZoomRotate = function PanZoomRotate(_ref) {
|
|
|
7447
7410
|
|
|
7448
7411
|
var config = useRecoilValue(BoardConfigAtom);
|
|
7449
7412
|
var setBoardState = useSetRecoilState(BoardStateAtom);
|
|
7450
|
-
var prevDim = usePrevious(dim);
|
|
7413
|
+
var prevDim = usePrevious(dim);
|
|
7414
|
+
var mouseRef = React.useRef({
|
|
7415
|
+
hover: false,
|
|
7416
|
+
x: 0,
|
|
7417
|
+
y: 0
|
|
7418
|
+
}); // Hooks to save/restore position
|
|
7451
7419
|
|
|
7452
7420
|
usePositionNavigator();
|
|
7453
7421
|
|
|
@@ -7482,7 +7450,7 @@ var PanZoomRotate = function PanZoomRotate(_ref) {
|
|
|
7482
7450
|
translateY: prevDimension.translateY + deltaY
|
|
7483
7451
|
});
|
|
7484
7452
|
});
|
|
7485
|
-
}, [scale, setDim]); // Center board on
|
|
7453
|
+
}, [scale, setDim]); // Center board on board loading
|
|
7486
7454
|
|
|
7487
7455
|
React.useEffect(function () {
|
|
7488
7456
|
var _boardRef$current$get = boardRef.current.getBoundingClientRect(),
|
|
@@ -7749,9 +7717,11 @@ var PanZoomRotate = function PanZoomRotate(_ref) {
|
|
|
7749
7717
|
e.preventDefault();
|
|
7750
7718
|
|
|
7751
7719
|
case 31:
|
|
7752
|
-
//
|
|
7720
|
+
// Temporary zoom
|
|
7753
7721
|
if (e.key === " " && !e.repeat) {
|
|
7754
|
-
|
|
7722
|
+
if (mouseRef.current.hover) {
|
|
7723
|
+
zoomTo(3, mouseRef.current);
|
|
7724
|
+
}
|
|
7755
7725
|
}
|
|
7756
7726
|
|
|
7757
7727
|
case 32:
|
|
@@ -7771,10 +7741,23 @@ var PanZoomRotate = function PanZoomRotate(_ref) {
|
|
|
7771
7741
|
// Ignore text in Input or Textarea
|
|
7772
7742
|
if (["INPUT", "TEXTAREA"].includes(e.target.tagName)) return; // Zoom out on release
|
|
7773
7743
|
|
|
7774
|
-
if (e.key === " ") {
|
|
7775
|
-
zoomTo(1 / 3);
|
|
7744
|
+
if (e.key === " " && mouseRef.current.hover) {
|
|
7745
|
+
zoomTo(1 / 3, mouseRef.current);
|
|
7776
7746
|
}
|
|
7777
|
-
}, [zoomTo]);
|
|
7747
|
+
}, [zoomTo]); // Save mouse position for temporary zoom
|
|
7748
|
+
|
|
7749
|
+
var onMouseMove = React.useCallback(function (e) {
|
|
7750
|
+
var clientX = e.clientX,
|
|
7751
|
+
clientY = e.clientY;
|
|
7752
|
+
mouseRef.current.x = clientX;
|
|
7753
|
+
mouseRef.current.y = clientY;
|
|
7754
|
+
}, []);
|
|
7755
|
+
var onMouseEnter = React.useCallback(function () {
|
|
7756
|
+
mouseRef.current.hover = true;
|
|
7757
|
+
}, []);
|
|
7758
|
+
var onMouseLeave = React.useCallback(function () {
|
|
7759
|
+
mouseRef.current.hover = false;
|
|
7760
|
+
}, []);
|
|
7778
7761
|
React.useEffect(function () {
|
|
7779
7762
|
document.addEventListener("keydown", onKeyDown);
|
|
7780
7763
|
document.addEventListener("keyup", onKeyUp);
|
|
@@ -7797,7 +7780,10 @@ var PanZoomRotate = function PanZoomRotate(_ref) {
|
|
|
7797
7780
|
ref: wrappedRef,
|
|
7798
7781
|
onContextMenu: function onContextMenu(e) {
|
|
7799
7782
|
e.preventDefault();
|
|
7800
|
-
}
|
|
7783
|
+
},
|
|
7784
|
+
onMouseMove: onMouseMove,
|
|
7785
|
+
onMouseEnter: onMouseEnter,
|
|
7786
|
+
onMouseLeave: onMouseLeave
|
|
7801
7787
|
}, children));
|
|
7802
7788
|
};
|
|
7803
7789
|
|
|
@@ -8189,6 +8175,13 @@ var Board = function Board(_ref) {
|
|
|
8189
8175
|
})))))), /*#__PURE__*/React.createElement(Selection, null));
|
|
8190
8176
|
};
|
|
8191
8177
|
|
|
8178
|
+
/**
|
|
8179
|
+
* Returns the default actions of an item
|
|
8180
|
+
* @param {object} item to consider
|
|
8181
|
+
* @param {object} itemMap item template map with default actions
|
|
8182
|
+
* @returns An array of default action for this item
|
|
8183
|
+
*/
|
|
8184
|
+
|
|
8192
8185
|
var getDefaultActionsFromItem = function getDefaultActionsFromItem(item, itemMap) {
|
|
8193
8186
|
if (item.type in itemMap) {
|
|
8194
8187
|
var actions = itemMap[item.type].defaultActions;
|
|
@@ -8202,27 +8195,26 @@ var getDefaultActionsFromItem = function getDefaultActionsFromItem(item, itemMap
|
|
|
8202
8195
|
|
|
8203
8196
|
return [];
|
|
8204
8197
|
};
|
|
8198
|
+
/**
|
|
8199
|
+
* Returns actual actions from an item ordered by the configured available
|
|
8200
|
+
* actions. If no action is defined, default actions are returned.
|
|
8201
|
+
* @param {object} item item to use
|
|
8202
|
+
* @param {object} itemMap item template map with available action for this item
|
|
8203
|
+
* @returns the array of actions for this item
|
|
8204
|
+
*/
|
|
8205
8205
|
|
|
8206
|
-
var getAvailableActionsFromItem = function getAvailableActionsFromItem(item, itemMap) {
|
|
8207
|
-
if (item.type in itemMap) {
|
|
8208
|
-
var actions = itemMap[item.type].availableActions;
|
|
8209
|
-
|
|
8210
|
-
if (typeof actions === "function") {
|
|
8211
|
-
return actions(item);
|
|
8212
|
-
}
|
|
8213
|
-
|
|
8214
|
-
return actions;
|
|
8215
|
-
}
|
|
8216
|
-
|
|
8217
|
-
return [];
|
|
8218
|
-
};
|
|
8219
8206
|
|
|
8220
8207
|
var getActionsFromItem = function getActionsFromItem(item, itemMap) {
|
|
8221
8208
|
var _item$actions = item.actions,
|
|
8222
|
-
actions = _item$actions === void 0 ? getDefaultActionsFromItem(item, itemMap) : _item$actions;
|
|
8209
|
+
actions = _item$actions === void 0 ? getDefaultActionsFromItem(item, itemMap) : _item$actions;
|
|
8210
|
+
return actions.map(function (action) {
|
|
8211
|
+
if (typeof action === "string") {
|
|
8212
|
+
return {
|
|
8213
|
+
name: action
|
|
8214
|
+
};
|
|
8215
|
+
}
|
|
8223
8216
|
|
|
8224
|
-
|
|
8225
|
-
return actions.includes(action);
|
|
8217
|
+
return action;
|
|
8226
8218
|
});
|
|
8227
8219
|
};
|
|
8228
8220
|
|
|
@@ -8292,6 +8284,11 @@ var useAvailableActions = function useAvailableActions() {
|
|
|
8292
8284
|
isMountedRef.current = false;
|
|
8293
8285
|
};
|
|
8294
8286
|
}, []);
|
|
8287
|
+
/**
|
|
8288
|
+
* Returns available actions for selected items. An action is kept only if all
|
|
8289
|
+
* items have this exact same action with same parameters.
|
|
8290
|
+
*/
|
|
8291
|
+
|
|
8295
8292
|
var updateAvailableActions = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
|
|
8296
8293
|
var _yield$getItemListOrS, _yield$getItemListOrS2, selectedItemIds, selectedItemList, allActions;
|
|
8297
8294
|
|
|
@@ -8324,8 +8321,10 @@ var useAvailableActions = function useAvailableActions() {
|
|
|
8324
8321
|
allActions = selectedItemList.reduce(function (acc, item) {
|
|
8325
8322
|
var itemActions = getActionsFromItem(item, itemMap);
|
|
8326
8323
|
return acc.filter(function (value) {
|
|
8327
|
-
return itemActions.
|
|
8328
|
-
|
|
8324
|
+
return itemActions.some(function (itemAction) {
|
|
8325
|
+
return es6(value, itemAction);
|
|
8326
|
+
});
|
|
8327
|
+
});
|
|
8329
8328
|
}, getActionsFromItem(selectedItemList[0], itemMap));
|
|
8330
8329
|
setAvailableActions(allActions);
|
|
8331
8330
|
_context2.next = 14;
|