kitchen-simulator 4.1.1-react-18 → 4.1.3-react-18
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/es/components/viewer2d/line.js +14 -12
- package/es/index.js +52 -15
- package/lib/components/viewer2d/line.js +14 -12
- package/lib/index.js +52 -15
- package/package.json +6 -2
|
@@ -252,7 +252,7 @@ export default function Line(_ref) {
|
|
|
252
252
|
if (Math.sin(angle) === 0 || GeometryUtils.almostEqual(y1, y2)) {
|
|
253
253
|
if (x1 - x2 > 0) {
|
|
254
254
|
return /*#__PURE__*/React.createElement("g", {
|
|
255
|
-
key: "
|
|
255
|
+
key: "baseRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
256
256
|
}, /*#__PURE__*/React.createElement("line", {
|
|
257
257
|
x1: pAw.pos.x + pAw.length,
|
|
258
258
|
y1: pAw.pos.y,
|
|
@@ -276,7 +276,7 @@ export default function Line(_ref) {
|
|
|
276
276
|
}));
|
|
277
277
|
} else {
|
|
278
278
|
return /*#__PURE__*/React.createElement("g", {
|
|
279
|
-
key: "
|
|
279
|
+
key: "baseRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
280
280
|
}, /*#__PURE__*/React.createElement("line", {
|
|
281
281
|
x1: pAw.pos.x + pAw.length,
|
|
282
282
|
y1: pAw.pos.y,
|
|
@@ -303,7 +303,7 @@ export default function Line(_ref) {
|
|
|
303
303
|
if (y1 - y2 > 0) {
|
|
304
304
|
if (x1 - x2 < 0 || GeometryUtils.almostEqual(x1, x2)) {
|
|
305
305
|
return /*#__PURE__*/React.createElement("g", {
|
|
306
|
-
key: "
|
|
306
|
+
key: "baseRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
307
307
|
}, /*#__PURE__*/React.createElement("line", {
|
|
308
308
|
x1: pAw.pos.x - pAw.length * Math.cos(angle / 180 * Math.PI),
|
|
309
309
|
y1: pAw.pos.y - pAw.length * Math.sin(angle / 180 * Math.PI),
|
|
@@ -327,7 +327,7 @@ export default function Line(_ref) {
|
|
|
327
327
|
}));
|
|
328
328
|
} else {
|
|
329
329
|
return /*#__PURE__*/React.createElement("g", {
|
|
330
|
-
key: "
|
|
330
|
+
key: "baseRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
331
331
|
}, /*#__PURE__*/React.createElement("line", {
|
|
332
332
|
x1: pAw.pos.x,
|
|
333
333
|
y1: pAw.pos.y,
|
|
@@ -353,7 +353,7 @@ export default function Line(_ref) {
|
|
|
353
353
|
} else {
|
|
354
354
|
if (x1 - x2 < 0 || GeometryUtils.almostEqual(x1, x2)) {
|
|
355
355
|
return /*#__PURE__*/React.createElement("g", {
|
|
356
|
-
key: "
|
|
356
|
+
key: "baseRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
357
357
|
}, /*#__PURE__*/React.createElement("line", {
|
|
358
358
|
x1: pAw.pos.x,
|
|
359
359
|
y1: pAw.pos.y,
|
|
@@ -377,7 +377,7 @@ export default function Line(_ref) {
|
|
|
377
377
|
}));
|
|
378
378
|
} else {
|
|
379
379
|
return /*#__PURE__*/React.createElement("g", {
|
|
380
|
-
key: "
|
|
380
|
+
key: "baseRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
381
381
|
}, /*#__PURE__*/React.createElement("line", {
|
|
382
382
|
x1: pAw.pos.x + pAw.length * Math.cos(angle / 180 * Math.PI),
|
|
383
383
|
y1: pAw.pos.y + pAw.length * Math.sin(angle / 180 * Math.PI),
|
|
@@ -476,7 +476,7 @@ export default function Line(_ref) {
|
|
|
476
476
|
if (Math.sin(angle) === 0 || GeometryUtils.almostEqual(y1, y2)) {
|
|
477
477
|
if (x1 - x2 > 0) {
|
|
478
478
|
return /*#__PURE__*/React.createElement("g", {
|
|
479
|
-
key: "
|
|
479
|
+
key: "wallRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
480
480
|
}, /*#__PURE__*/React.createElement("line", {
|
|
481
481
|
x1: pAw.pos.x + pAw.length,
|
|
482
482
|
y1: pAw.pos.y,
|
|
@@ -500,7 +500,7 @@ export default function Line(_ref) {
|
|
|
500
500
|
}));
|
|
501
501
|
} else {
|
|
502
502
|
return /*#__PURE__*/React.createElement("g", {
|
|
503
|
-
key: "
|
|
503
|
+
key: "wallRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
504
504
|
}, /*#__PURE__*/React.createElement("line", {
|
|
505
505
|
x1: pAw.pos.x + pAw.length,
|
|
506
506
|
y1: pAw.pos.y,
|
|
@@ -527,7 +527,7 @@ export default function Line(_ref) {
|
|
|
527
527
|
if (y1 - y2 > 0) {
|
|
528
528
|
if (x1 - x2 < 0 || GeometryUtils.almostEqual(x1, x2)) {
|
|
529
529
|
return /*#__PURE__*/React.createElement("g", {
|
|
530
|
-
key: "
|
|
530
|
+
key: "wallRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
531
531
|
}, /*#__PURE__*/React.createElement("line", {
|
|
532
532
|
x1: pAw.pos.x - pAw.length * Math.cos(angle / 180 * Math.PI),
|
|
533
533
|
y1: pAw.pos.y - pAw.length * Math.sin(angle / 180 * Math.PI),
|
|
@@ -551,7 +551,7 @@ export default function Line(_ref) {
|
|
|
551
551
|
}));
|
|
552
552
|
} else {
|
|
553
553
|
return /*#__PURE__*/React.createElement("g", {
|
|
554
|
-
key: "
|
|
554
|
+
key: "wallRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
555
555
|
}, /*#__PURE__*/React.createElement("line", {
|
|
556
556
|
x1: pAw.pos.x,
|
|
557
557
|
y1: pAw.pos.y,
|
|
@@ -577,7 +577,7 @@ export default function Line(_ref) {
|
|
|
577
577
|
} else {
|
|
578
578
|
if (x1 - x2 < 0 || GeometryUtils.almostEqual(x1, x2)) {
|
|
579
579
|
return /*#__PURE__*/React.createElement("g", {
|
|
580
|
-
key: "
|
|
580
|
+
key: "wallRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
581
581
|
}, /*#__PURE__*/React.createElement("line", {
|
|
582
582
|
x1: pAw.pos.x,
|
|
583
583
|
y1: pAw.pos.y,
|
|
@@ -601,7 +601,7 @@ export default function Line(_ref) {
|
|
|
601
601
|
}));
|
|
602
602
|
} else {
|
|
603
603
|
return /*#__PURE__*/React.createElement("g", {
|
|
604
|
-
key: "
|
|
604
|
+
key: "wallRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
605
605
|
}, /*#__PURE__*/React.createElement("line", {
|
|
606
606
|
x1: pAw.pos.x + pAw.length * Math.cos(angle / 180 * Math.PI),
|
|
607
607
|
y1: pAw.pos.y + pAw.length * Math.sin(angle / 180 * Math.PI),
|
|
@@ -751,6 +751,7 @@ export default function Line(_ref) {
|
|
|
751
751
|
}
|
|
752
752
|
if (compareVertices(vertex0, vertex1) >= 0 && vertex0.x !== vertex1.x) {
|
|
753
753
|
renderedAllRuler.push(/*#__PURE__*/React.createElement("g", {
|
|
754
|
+
key: "allRuler-".concat(index, "-").concat(allRuler[index]),
|
|
754
755
|
transform: "translate(".concat(x1, ", ").concat(y1, ") rotate(").concat(angle, ", 0, 0)")
|
|
755
756
|
}, /*#__PURE__*/React.createElement("line", {
|
|
756
757
|
x1: allRuler[index],
|
|
@@ -775,6 +776,7 @@ export default function Line(_ref) {
|
|
|
775
776
|
})));
|
|
776
777
|
} else {
|
|
777
778
|
renderedAllRuler.push(/*#__PURE__*/React.createElement("g", {
|
|
779
|
+
key: "allRuler-".concat(index, "-").concat(allRuler[index]),
|
|
778
780
|
transform: "translate(".concat(x1, ", ").concat(y1, ") rotate(").concat(angle, ", 0, 0)")
|
|
779
781
|
}, /*#__PURE__*/React.createElement("line", {
|
|
780
782
|
x1: allRuler[index],
|
package/es/index.js
CHANGED
|
@@ -9,33 +9,70 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import { createRoot } from 'react-dom/client';
|
|
11
11
|
import LiteRenderer from "./LiteRenderer";
|
|
12
|
-
import { flushSync } from 'react-dom';
|
|
13
12
|
export function renderKitchenSimulator(container) {
|
|
14
13
|
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
// Internal wrapper that exposes a state setter
|
|
14
|
+
var apiRef = null;
|
|
18
15
|
var Wrapper = /*#__PURE__*/function (_React$Component) {
|
|
19
16
|
function Wrapper(p) {
|
|
20
17
|
var _this;
|
|
21
18
|
_classCallCheck(this, Wrapper);
|
|
22
19
|
_this = _callSuper(this, Wrapper, [p]);
|
|
23
20
|
_this.state = {
|
|
24
|
-
externalEvent:
|
|
21
|
+
externalEvent: null
|
|
22
|
+
};
|
|
23
|
+
_this.queue = [];
|
|
24
|
+
_this.processing = false;
|
|
25
|
+
apiRef = {
|
|
26
|
+
enqueueExternalEvent: function enqueueExternalEvent(ev) {
|
|
27
|
+
return _this.enqueue(ev);
|
|
28
|
+
},
|
|
29
|
+
unmount: function unmount() {}
|
|
25
30
|
};
|
|
26
|
-
setExternalEventFn = _this.setExternalEvent.bind(_this);
|
|
27
31
|
return _this;
|
|
28
32
|
}
|
|
29
33
|
_inherits(Wrapper, _React$Component);
|
|
30
34
|
return _createClass(Wrapper, [{
|
|
31
|
-
key: "
|
|
32
|
-
value: function
|
|
35
|
+
key: "enqueue",
|
|
36
|
+
value: function enqueue(ev) {
|
|
37
|
+
if (!ev) return;
|
|
38
|
+
this.queue.push(ev);
|
|
39
|
+
if (!this.processing) this.processNext();
|
|
40
|
+
}
|
|
41
|
+
}, {
|
|
42
|
+
key: "processNext",
|
|
43
|
+
value: function processNext() {
|
|
33
44
|
var _this2 = this;
|
|
34
|
-
|
|
45
|
+
var next = this.queue.shift();
|
|
46
|
+
if (!next) {
|
|
47
|
+
this.processing = false;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
this.processing = true;
|
|
51
|
+
|
|
52
|
+
// Separate task => prevents React 18 batching from collapsing updates
|
|
53
|
+
setTimeout(function () {
|
|
54
|
+
// setting null first ensures `prevProps.externalEvent !== externalEvent`
|
|
55
|
+
// even if two events are referentially equal or key logic is weird
|
|
35
56
|
_this2.setState({
|
|
36
|
-
externalEvent:
|
|
57
|
+
externalEvent: null
|
|
58
|
+
}, function () {
|
|
59
|
+
_this2.setState({
|
|
60
|
+
externalEvent: next
|
|
61
|
+
});
|
|
37
62
|
});
|
|
38
|
-
});
|
|
63
|
+
}, 0);
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "componentDidUpdate",
|
|
67
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
68
|
+
var _this3 = this;
|
|
69
|
+
// When the event was delivered, schedule the next one
|
|
70
|
+
if (prevState.externalEvent !== this.state.externalEvent) {
|
|
71
|
+
// Give LiteKitchenConfigurator a chance to react in its componentDidUpdate
|
|
72
|
+
setTimeout(function () {
|
|
73
|
+
return _this3.processNext();
|
|
74
|
+
}, 0);
|
|
75
|
+
}
|
|
39
76
|
}
|
|
40
77
|
}, {
|
|
41
78
|
key: "render",
|
|
@@ -45,17 +82,17 @@ export function renderKitchenSimulator(container) {
|
|
|
45
82
|
}));
|
|
46
83
|
}
|
|
47
84
|
}]);
|
|
48
|
-
}(React.Component);
|
|
85
|
+
}(React.Component);
|
|
49
86
|
var root = createRoot(container);
|
|
50
87
|
root.render(/*#__PURE__*/React.createElement(Wrapper, props));
|
|
51
88
|
return {
|
|
52
89
|
updateExternalEvent: function updateExternalEvent(newExternalEvent) {
|
|
53
|
-
var
|
|
54
|
-
(
|
|
90
|
+
var _apiRef, _apiRef$enqueueExtern;
|
|
91
|
+
(_apiRef = apiRef) === null || _apiRef === void 0 || (_apiRef$enqueueExtern = _apiRef.enqueueExternalEvent) === null || _apiRef$enqueueExtern === void 0 || _apiRef$enqueueExtern.call(_apiRef, newExternalEvent);
|
|
55
92
|
},
|
|
56
93
|
unmount: function unmount() {
|
|
57
94
|
root.unmount();
|
|
58
|
-
|
|
95
|
+
apiRef = null;
|
|
59
96
|
}
|
|
60
97
|
};
|
|
61
98
|
}
|
|
@@ -263,7 +263,7 @@ function Line(_ref) {
|
|
|
263
263
|
if (Math.sin(angle) === 0 || _export.GeometryUtils.almostEqual(y1, y2)) {
|
|
264
264
|
if (x1 - x2 > 0) {
|
|
265
265
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
266
|
-
key: "
|
|
266
|
+
key: "baseRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
267
267
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
268
268
|
x1: pAw.pos.x + pAw.length,
|
|
269
269
|
y1: pAw.pos.y,
|
|
@@ -287,7 +287,7 @@ function Line(_ref) {
|
|
|
287
287
|
}));
|
|
288
288
|
} else {
|
|
289
289
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
290
|
-
key: "
|
|
290
|
+
key: "baseRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
291
291
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
292
292
|
x1: pAw.pos.x + pAw.length,
|
|
293
293
|
y1: pAw.pos.y,
|
|
@@ -314,7 +314,7 @@ function Line(_ref) {
|
|
|
314
314
|
if (y1 - y2 > 0) {
|
|
315
315
|
if (x1 - x2 < 0 || _export.GeometryUtils.almostEqual(x1, x2)) {
|
|
316
316
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
317
|
-
key: "
|
|
317
|
+
key: "baseRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
318
318
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
319
319
|
x1: pAw.pos.x - pAw.length * Math.cos(angle / 180 * Math.PI),
|
|
320
320
|
y1: pAw.pos.y - pAw.length * Math.sin(angle / 180 * Math.PI),
|
|
@@ -338,7 +338,7 @@ function Line(_ref) {
|
|
|
338
338
|
}));
|
|
339
339
|
} else {
|
|
340
340
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
341
|
-
key: "
|
|
341
|
+
key: "baseRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
342
342
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
343
343
|
x1: pAw.pos.x,
|
|
344
344
|
y1: pAw.pos.y,
|
|
@@ -364,7 +364,7 @@ function Line(_ref) {
|
|
|
364
364
|
} else {
|
|
365
365
|
if (x1 - x2 < 0 || _export.GeometryUtils.almostEqual(x1, x2)) {
|
|
366
366
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
367
|
-
key: "
|
|
367
|
+
key: "baseRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
368
368
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
369
369
|
x1: pAw.pos.x,
|
|
370
370
|
y1: pAw.pos.y,
|
|
@@ -388,7 +388,7 @@ function Line(_ref) {
|
|
|
388
388
|
}));
|
|
389
389
|
} else {
|
|
390
390
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
391
|
-
key: "
|
|
391
|
+
key: "baseRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
392
392
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
393
393
|
x1: pAw.pos.x + pAw.length * Math.cos(angle / 180 * Math.PI),
|
|
394
394
|
y1: pAw.pos.y + pAw.length * Math.sin(angle / 180 * Math.PI),
|
|
@@ -487,7 +487,7 @@ function Line(_ref) {
|
|
|
487
487
|
if (Math.sin(angle) === 0 || _export.GeometryUtils.almostEqual(y1, y2)) {
|
|
488
488
|
if (x1 - x2 > 0) {
|
|
489
489
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
490
|
-
key: "
|
|
490
|
+
key: "wallRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
491
491
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
492
492
|
x1: pAw.pos.x + pAw.length,
|
|
493
493
|
y1: pAw.pos.y,
|
|
@@ -511,7 +511,7 @@ function Line(_ref) {
|
|
|
511
511
|
}));
|
|
512
512
|
} else {
|
|
513
513
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
514
|
-
key: "
|
|
514
|
+
key: "wallRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
515
515
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
516
516
|
x1: pAw.pos.x + pAw.length,
|
|
517
517
|
y1: pAw.pos.y,
|
|
@@ -538,7 +538,7 @@ function Line(_ref) {
|
|
|
538
538
|
if (y1 - y2 > 0) {
|
|
539
539
|
if (x1 - x2 < 0 || _export.GeometryUtils.almostEqual(x1, x2)) {
|
|
540
540
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
541
|
-
key: "
|
|
541
|
+
key: "wallRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
542
542
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
543
543
|
x1: pAw.pos.x - pAw.length * Math.cos(angle / 180 * Math.PI),
|
|
544
544
|
y1: pAw.pos.y - pAw.length * Math.sin(angle / 180 * Math.PI),
|
|
@@ -562,7 +562,7 @@ function Line(_ref) {
|
|
|
562
562
|
}));
|
|
563
563
|
} else {
|
|
564
564
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
565
|
-
key: "
|
|
565
|
+
key: "wallRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
566
566
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
567
567
|
x1: pAw.pos.x,
|
|
568
568
|
y1: pAw.pos.y,
|
|
@@ -588,7 +588,7 @@ function Line(_ref) {
|
|
|
588
588
|
} else {
|
|
589
589
|
if (x1 - x2 < 0 || _export.GeometryUtils.almostEqual(x1, x2)) {
|
|
590
590
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
591
|
-
key: "
|
|
591
|
+
key: "wallRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
592
592
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
593
593
|
x1: pAw.pos.x,
|
|
594
594
|
y1: pAw.pos.y,
|
|
@@ -612,7 +612,7 @@ function Line(_ref) {
|
|
|
612
612
|
}));
|
|
613
613
|
} else {
|
|
614
614
|
return /*#__PURE__*/_react["default"].createElement("g", {
|
|
615
|
-
key: "
|
|
615
|
+
key: "wallRuler-".concat(idx, "-").concat(pAw.pos.x, "-").concat(pAw.pos.y)
|
|
616
616
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
617
617
|
x1: pAw.pos.x + pAw.length * Math.cos(angle / 180 * Math.PI),
|
|
618
618
|
y1: pAw.pos.y + pAw.length * Math.sin(angle / 180 * Math.PI),
|
|
@@ -762,6 +762,7 @@ function Line(_ref) {
|
|
|
762
762
|
}
|
|
763
763
|
if (compareVertices(vertex0, vertex1) >= 0 && vertex0.x !== vertex1.x) {
|
|
764
764
|
renderedAllRuler.push(/*#__PURE__*/_react["default"].createElement("g", {
|
|
765
|
+
key: "allRuler-".concat(index, "-").concat(allRuler[index]),
|
|
765
766
|
transform: "translate(".concat(x1, ", ").concat(y1, ") rotate(").concat(angle, ", 0, 0)")
|
|
766
767
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
767
768
|
x1: allRuler[index],
|
|
@@ -786,6 +787,7 @@ function Line(_ref) {
|
|
|
786
787
|
})));
|
|
787
788
|
} else {
|
|
788
789
|
renderedAllRuler.push(/*#__PURE__*/_react["default"].createElement("g", {
|
|
790
|
+
key: "allRuler-".concat(index, "-").concat(allRuler[index]),
|
|
789
791
|
transform: "translate(".concat(x1, ", ").concat(y1, ") rotate(").concat(angle, ", 0, 0)")
|
|
790
792
|
}, /*#__PURE__*/_react["default"].createElement("line", {
|
|
791
793
|
x1: allRuler[index],
|
package/lib/index.js
CHANGED
|
@@ -15,35 +15,72 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
15
15
|
var _react = _interopRequireDefault(require("react"));
|
|
16
16
|
var _client = require("react-dom/client");
|
|
17
17
|
var _LiteRenderer = _interopRequireDefault(require("./LiteRenderer"));
|
|
18
|
-
var _reactDom = require("react-dom");
|
|
19
18
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
20
19
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
21
20
|
function renderKitchenSimulator(container) {
|
|
22
21
|
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
// Internal wrapper that exposes a state setter
|
|
22
|
+
var apiRef = null;
|
|
26
23
|
var Wrapper = /*#__PURE__*/function (_React$Component) {
|
|
27
24
|
function Wrapper(p) {
|
|
28
25
|
var _this;
|
|
29
26
|
(0, _classCallCheck2["default"])(this, Wrapper);
|
|
30
27
|
_this = _callSuper(this, Wrapper, [p]);
|
|
31
28
|
_this.state = {
|
|
32
|
-
externalEvent:
|
|
29
|
+
externalEvent: null
|
|
30
|
+
};
|
|
31
|
+
_this.queue = [];
|
|
32
|
+
_this.processing = false;
|
|
33
|
+
apiRef = {
|
|
34
|
+
enqueueExternalEvent: function enqueueExternalEvent(ev) {
|
|
35
|
+
return _this.enqueue(ev);
|
|
36
|
+
},
|
|
37
|
+
unmount: function unmount() {}
|
|
33
38
|
};
|
|
34
|
-
setExternalEventFn = _this.setExternalEvent.bind(_this);
|
|
35
39
|
return _this;
|
|
36
40
|
}
|
|
37
41
|
(0, _inherits2["default"])(Wrapper, _React$Component);
|
|
38
42
|
return (0, _createClass2["default"])(Wrapper, [{
|
|
39
|
-
key: "
|
|
40
|
-
value: function
|
|
43
|
+
key: "enqueue",
|
|
44
|
+
value: function enqueue(ev) {
|
|
45
|
+
if (!ev) return;
|
|
46
|
+
this.queue.push(ev);
|
|
47
|
+
if (!this.processing) this.processNext();
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
key: "processNext",
|
|
51
|
+
value: function processNext() {
|
|
41
52
|
var _this2 = this;
|
|
42
|
-
|
|
53
|
+
var next = this.queue.shift();
|
|
54
|
+
if (!next) {
|
|
55
|
+
this.processing = false;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.processing = true;
|
|
59
|
+
|
|
60
|
+
// Separate task => prevents React 18 batching from collapsing updates
|
|
61
|
+
setTimeout(function () {
|
|
62
|
+
// setting null first ensures `prevProps.externalEvent !== externalEvent`
|
|
63
|
+
// even if two events are referentially equal or key logic is weird
|
|
43
64
|
_this2.setState({
|
|
44
|
-
externalEvent:
|
|
65
|
+
externalEvent: null
|
|
66
|
+
}, function () {
|
|
67
|
+
_this2.setState({
|
|
68
|
+
externalEvent: next
|
|
69
|
+
});
|
|
45
70
|
});
|
|
46
|
-
});
|
|
71
|
+
}, 0);
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "componentDidUpdate",
|
|
75
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
76
|
+
var _this3 = this;
|
|
77
|
+
// When the event was delivered, schedule the next one
|
|
78
|
+
if (prevState.externalEvent !== this.state.externalEvent) {
|
|
79
|
+
// Give LiteKitchenConfigurator a chance to react in its componentDidUpdate
|
|
80
|
+
setTimeout(function () {
|
|
81
|
+
return _this3.processNext();
|
|
82
|
+
}, 0);
|
|
83
|
+
}
|
|
47
84
|
}
|
|
48
85
|
}, {
|
|
49
86
|
key: "render",
|
|
@@ -53,17 +90,17 @@ function renderKitchenSimulator(container) {
|
|
|
53
90
|
}));
|
|
54
91
|
}
|
|
55
92
|
}]);
|
|
56
|
-
}(_react["default"].Component);
|
|
93
|
+
}(_react["default"].Component);
|
|
57
94
|
var root = (0, _client.createRoot)(container);
|
|
58
95
|
root.render(/*#__PURE__*/_react["default"].createElement(Wrapper, props));
|
|
59
96
|
return {
|
|
60
97
|
updateExternalEvent: function updateExternalEvent(newExternalEvent) {
|
|
61
|
-
var
|
|
62
|
-
(
|
|
98
|
+
var _apiRef, _apiRef$enqueueExtern;
|
|
99
|
+
(_apiRef = apiRef) === null || _apiRef === void 0 || (_apiRef$enqueueExtern = _apiRef.enqueueExternalEvent) === null || _apiRef$enqueueExtern === void 0 || _apiRef$enqueueExtern.call(_apiRef, newExternalEvent);
|
|
63
100
|
},
|
|
64
101
|
unmount: function unmount() {
|
|
65
102
|
root.unmount();
|
|
66
|
-
|
|
103
|
+
apiRef = null;
|
|
67
104
|
}
|
|
68
105
|
};
|
|
69
106
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kitchen-simulator",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3-react-18",
|
|
4
4
|
"description": "It is a kitchen simulator (self-contained micro-frontend).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -85,11 +85,15 @@
|
|
|
85
85
|
"react-svg-pan-zoom": "^3.13.1",
|
|
86
86
|
"react-use-measure": "^2.1.7",
|
|
87
87
|
"redux": "^5.0.1",
|
|
88
|
-
"three": "0.166.0"
|
|
88
|
+
"three": "0.166.0"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
89
91
|
"react": "^18.3.1",
|
|
90
92
|
"react-dom": "^18.3.1"
|
|
91
93
|
},
|
|
92
94
|
"devDependencies": {
|
|
95
|
+
"react": "^18.3.1",
|
|
96
|
+
"react-dom": "^18.3.1",
|
|
93
97
|
"@babel/cli": "^7.28.3",
|
|
94
98
|
"@babel/core": "^7.28.4",
|
|
95
99
|
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
|