kitchen-simulator 3.12.0-test.3 → 3.13.0
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/class/item.js +28 -17
- package/es/class/project.js +2 -2
- package/es/index.js +5 -102
- package/es/utils/geometry.js +1 -1
- package/lib/class/item.js +27 -16
- package/lib/class/project.js +2 -2
- package/lib/index.js +5 -102
- package/lib/utils/geometry.js +1 -1
- package/package.json +1 -1
package/es/class/item.js
CHANGED
|
@@ -12,7 +12,7 @@ import { INSTALLATION_SUFFIX_TYPE, INTERNAL_EVENT_DRAW_ELEMENT, MODE_DRAGGING_IT
|
|
|
12
12
|
import { debugUtil, updatePayloadOfInternalEvent } from "../utils/helper";
|
|
13
13
|
import { isUndefined } from 'util';
|
|
14
14
|
import { hasMoldingLayout } from "../utils/molding";
|
|
15
|
-
import { getInstallationSuffix } from "../components/viewer2d/utils";
|
|
15
|
+
import { getInstallationSuffix, isEmpty } from "../components/viewer2d/utils";
|
|
16
16
|
import { historyPush } from "../utils/history";
|
|
17
17
|
var allItemRect;
|
|
18
18
|
var allItemSnap;
|
|
@@ -29,9 +29,11 @@ var Item = /*#__PURE__*/function () {
|
|
|
29
29
|
return _createClass(Item, null, [{
|
|
30
30
|
key: "create",
|
|
31
31
|
value: function create(state, layerID, type, x, y, width, height, rotation, isDuplication) {
|
|
32
|
+
var _item;
|
|
32
33
|
var molding = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : [];
|
|
33
34
|
var isInitialPos = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false;
|
|
34
35
|
var refItem = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : null;
|
|
36
|
+
var counterTopURI = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : null;
|
|
35
37
|
var itemID = IDBroker.acquireID();
|
|
36
38
|
var item = state.catalog.factoryElement(type, {
|
|
37
39
|
id: itemID,
|
|
@@ -160,6 +162,9 @@ var Item = /*#__PURE__*/function () {
|
|
|
160
162
|
}
|
|
161
163
|
};
|
|
162
164
|
item.category === 'cabinet' && setSizeOfItemByDoorStyle();
|
|
165
|
+
if (counterTopURI || (_item = item) !== null && _item !== void 0 && _item.counterTop) {
|
|
166
|
+
item.counterTop.uri = counterTopURI;
|
|
167
|
+
}
|
|
163
168
|
item = this.updateDoorHandle(item, state.getIn(['scene', 'layers', layerID]));
|
|
164
169
|
state = state.setIn(['scene', 'layers', layerID, 'items', itemID], item);
|
|
165
170
|
if (item.type.includes('Light')) {
|
|
@@ -331,17 +336,17 @@ var Item = /*#__PURE__*/function () {
|
|
|
331
336
|
if (isRect) {
|
|
332
337
|
var _this$create2 = this.create(state, layerID, sceneComponentType, x - width * Math.cos(rotRad), y - width * Math.sin(rotRad), 200, 100, rotRad * 180 / Math.PI, true, myObject.molding, false, myObject),
|
|
333
338
|
_stateI = _this$create2.updatedState,
|
|
334
|
-
|
|
335
|
-
duplicatedElement =
|
|
336
|
-
if (
|
|
339
|
+
_item2 = _this$create2.item;
|
|
340
|
+
duplicatedElement = _item2;
|
|
341
|
+
if (_item2 === null) {
|
|
337
342
|
alert('There are no Door Colors in this cabinet.');
|
|
338
343
|
state = state.merge({
|
|
339
344
|
mode: MODE_IDLE,
|
|
340
345
|
drawingSupport: new Map()
|
|
341
346
|
});
|
|
342
347
|
} else {
|
|
343
|
-
state = Item.select(_stateI, layerID,
|
|
344
|
-
state = state.setIn(['drawingSupport', 'currentID'],
|
|
348
|
+
state = Item.select(_stateI, layerID, _item2.id).updatedState;
|
|
349
|
+
state = state.setIn(['drawingSupport', 'currentID'], _item2.id);
|
|
345
350
|
}
|
|
346
351
|
} else {
|
|
347
352
|
var _val2 = {
|
|
@@ -358,17 +363,17 @@ var Item = /*#__PURE__*/function () {
|
|
|
358
363
|
if (isRectDown) {
|
|
359
364
|
var _this$create3 = this.create(state, layerID, sceneComponentType, x - depth * Math.sin(rotRad), y - depth * Math.cos(rotRad), 200, 100, rotRad * 180 / Math.PI, true, myObject.molding, false, myObject),
|
|
360
365
|
_stateI2 = _this$create3.updatedState,
|
|
361
|
-
|
|
362
|
-
duplicatedElement =
|
|
363
|
-
if (
|
|
366
|
+
_item3 = _this$create3.item;
|
|
367
|
+
duplicatedElement = _item3;
|
|
368
|
+
if (_item3 === null) {
|
|
364
369
|
alert('There are no Door Colors in this cabinet.');
|
|
365
370
|
state = state.merge({
|
|
366
371
|
mode: MODE_IDLE,
|
|
367
372
|
drawingSupport: new Map()
|
|
368
373
|
});
|
|
369
374
|
} else {
|
|
370
|
-
state = Item.select(_stateI2, layerID,
|
|
371
|
-
state = state.setIn(['drawingSupport', 'currentID'],
|
|
375
|
+
state = Item.select(_stateI2, layerID, _item3.id).updatedState;
|
|
376
|
+
state = state.setIn(['drawingSupport', 'currentID'], _item3.id);
|
|
372
377
|
}
|
|
373
378
|
} else {
|
|
374
379
|
var _val3 = {
|
|
@@ -385,17 +390,17 @@ var Item = /*#__PURE__*/function () {
|
|
|
385
390
|
if (isRectUp) {
|
|
386
391
|
var _this$create4 = this.create(state, layerID, sceneComponentType, x + depth * Math.sin(rotRad), y + depth * Math.cos(rotRad), 200, 100, rotRad * 180 / Math.PI, true, myObject.molding, false, myObject),
|
|
387
392
|
_stateI3 = _this$create4.updatedState,
|
|
388
|
-
|
|
389
|
-
duplicatedElement =
|
|
390
|
-
if (
|
|
393
|
+
_item4 = _this$create4.item;
|
|
394
|
+
duplicatedElement = _item4;
|
|
395
|
+
if (_item4 === null) {
|
|
391
396
|
alert('There are no Door Colors in this cabinet.');
|
|
392
397
|
state = state.merge({
|
|
393
398
|
mode: MODE_IDLE,
|
|
394
399
|
drawingSupport: new Map()
|
|
395
400
|
});
|
|
396
401
|
} else {
|
|
397
|
-
state = Item.select(_stateI3, layerID,
|
|
398
|
-
state = state.setIn(['drawingSupport', 'currentID'],
|
|
402
|
+
state = Item.select(_stateI3, layerID, _item4.id).updatedState;
|
|
403
|
+
state = state.setIn(['drawingSupport', 'currentID'], _item4.id);
|
|
399
404
|
}
|
|
400
405
|
} else {
|
|
401
406
|
console.log('there is no space');
|
|
@@ -532,8 +537,14 @@ var Item = /*#__PURE__*/function () {
|
|
|
532
537
|
}, {
|
|
533
538
|
key: "replaceItem",
|
|
534
539
|
value: function replaceItem(state, selectedPos, currentObject, selectedObject) {
|
|
540
|
+
var _currentObject$counte;
|
|
541
|
+
var counterTopURI = '';
|
|
542
|
+
if (!isEmpty(currentObject === null || currentObject === void 0 || (_currentObject$counte = currentObject.counterTop) === null || _currentObject$counte === void 0 ? void 0 : _currentObject$counte.uri)) {
|
|
543
|
+
var _currentObject$counte2;
|
|
544
|
+
counterTopURI = currentObject === null || currentObject === void 0 || (_currentObject$counte2 = currentObject.counterTop) === null || _currentObject$counte2 === void 0 ? void 0 : _currentObject$counte2.uri;
|
|
545
|
+
} else if (!isEmpty(state.getIn(['scene', 'layers', 'layer-1', 'counterTop']))) counterTopURI = state.getIn(['scene', 'layers', 'layer-1', 'counterTop']).uri;else counterTopURI = 'https://media.test.diydesignspace.com/uploads/CountTop/202105074107_5/texture/Unique_Calcatta_texture.jpg';
|
|
535
546
|
state = this.remove(state, state.scene.selectedLayer, selectedPos.selectedItemId).updatedState;
|
|
536
|
-
state = this.create(state, state.scene.selectedLayer, selectedObject.name, selectedPos.x, selectedPos.y, selectedObject.info.width, selectedObject.info.height, selectedPos.rotation, false).updatedState;
|
|
547
|
+
state = this.create(state, state.scene.selectedLayer, selectedObject.name, selectedPos.x, selectedPos.y, selectedObject.info.width, selectedObject.info.height, selectedPos.rotation, false, [], false, null, counterTopURI).updatedState;
|
|
537
548
|
// state = this.select(state, state.scene.selectedLayer, selectedPos.selectedItemId).updatedState;
|
|
538
549
|
return {
|
|
539
550
|
updatedState: state
|
package/es/class/project.js
CHANGED
|
@@ -835,8 +835,8 @@ var Project = /*#__PURE__*/function () {
|
|
|
835
835
|
});
|
|
836
836
|
var _viewer2D = state.viewer2D;
|
|
837
837
|
var viewer = _viewer2D.toJS();
|
|
838
|
-
width = convert(width).from('
|
|
839
|
-
height = convert(height).from('
|
|
838
|
+
width = convert(width).from(state.getIn(['scene', 'layers', 'layer-1', 'unit'])).to('cm');
|
|
839
|
+
height = convert(height).from(state.getIn(['scene', 'layers', 'layer-1', 'unit'])).to('cm');
|
|
840
840
|
var layerID = state.scene.selectedLayer;
|
|
841
841
|
state = Item.setInitialDoorStyle(state, doorStyle).updatedState;
|
|
842
842
|
if (isEmpty(viewer)) return {
|
package/es/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
@@ -6,8 +5,6 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
|
|
|
6
5
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
6
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
7
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
9
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
8
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
9
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
10
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
@@ -249,10 +246,10 @@ export function renderKitchenSimulator(container) {
|
|
|
249
246
|
|
|
250
247
|
// ✅ Reuse existing API for same container
|
|
251
248
|
if (container[API_KEY]) {
|
|
252
|
-
var
|
|
253
|
-
|
|
254
|
-
(
|
|
255
|
-
return
|
|
249
|
+
var _container$API_KEY$__, _container$API_KEY;
|
|
250
|
+
// update render with latest props (safe)
|
|
251
|
+
(_container$API_KEY$__ = (_container$API_KEY = container[API_KEY]).__render) === null || _container$API_KEY$__ === void 0 || _container$API_KEY$__.call(_container$API_KEY, props);
|
|
252
|
+
return container[API_KEY];
|
|
256
253
|
}
|
|
257
254
|
|
|
258
255
|
// ✅ Reuse root for same container
|
|
@@ -447,79 +444,10 @@ export function renderKitchenSimulator(container) {
|
|
|
447
444
|
}
|
|
448
445
|
}]);
|
|
449
446
|
}(React.Component);
|
|
450
|
-
var ro = null;
|
|
451
|
-
var roEl = null;
|
|
452
|
-
var roRaf = 0;
|
|
453
|
-
function installContentBoxObserver() {
|
|
454
|
-
var _lastProps$width2, _lastProps$height2;
|
|
455
|
-
if (typeof window === 'undefined') return;
|
|
456
|
-
if (typeof ResizeObserver === 'undefined') return;
|
|
457
|
-
var el = document.getElementById('content-box');
|
|
458
|
-
if (!el) return; // tool won't crash if element isn't there yet
|
|
459
|
-
|
|
460
|
-
roEl = el;
|
|
461
|
-
var syncFromEl = function syncFromEl(entry) {
|
|
462
|
-
var _lastProps$width, _lastProps$height;
|
|
463
|
-
// Prefer contentBoxSize when available; fallback to getBoundingClientRect.
|
|
464
|
-
var w = 0,
|
|
465
|
-
h = 0;
|
|
466
|
-
var cbs = entry === null || entry === void 0 ? void 0 : entry.contentBoxSize;
|
|
467
|
-
if (cbs) {
|
|
468
|
-
var _box$inlineSize, _box$blockSize;
|
|
469
|
-
// contentBoxSize can be array (Chrome) or single object (Firefox)
|
|
470
|
-
var box = Array.isArray(cbs) ? cbs[0] : cbs;
|
|
471
|
-
w = (_box$inlineSize = box === null || box === void 0 ? void 0 : box.inlineSize) !== null && _box$inlineSize !== void 0 ? _box$inlineSize : 0;
|
|
472
|
-
h = (_box$blockSize = box === null || box === void 0 ? void 0 : box.blockSize) !== null && _box$blockSize !== void 0 ? _box$blockSize : 0;
|
|
473
|
-
}
|
|
474
|
-
if (!w || !h) {
|
|
475
|
-
var _rect = roEl.getBoundingClientRect();
|
|
476
|
-
w = _rect.width;
|
|
477
|
-
h = _rect.height;
|
|
478
|
-
}
|
|
479
|
-
w = normalizeSize(w, (_lastProps$width = lastProps.width) !== null && _lastProps$width !== void 0 ? _lastProps$width : 1);
|
|
480
|
-
h = normalizeSize(h, (_lastProps$height = lastProps.height) !== null && _lastProps$height !== void 0 ? _lastProps$height : 1);
|
|
481
|
-
|
|
482
|
-
// avoid thrash: coalesce multiple observer callbacks into 1 RAF
|
|
483
|
-
if (roRaf) cancelAnimationFrame(roRaf);
|
|
484
|
-
roRaf = requestAnimationFrame(function () {
|
|
485
|
-
roRaf = 0;
|
|
486
|
-
if (destroyed) return;
|
|
487
|
-
// only update if changed (prevents infinite loops)
|
|
488
|
-
if (lastProps.width === w && lastProps.height === h) return;
|
|
489
|
-
// update props via existing render path
|
|
490
|
-
api.__render({
|
|
491
|
-
width: w,
|
|
492
|
-
height: h
|
|
493
|
-
});
|
|
494
|
-
});
|
|
495
|
-
};
|
|
496
|
-
ro = new ResizeObserver(function (entries) {
|
|
497
|
-
var entry = entries && entries[0];
|
|
498
|
-
if (!entry) return;
|
|
499
|
-
syncFromEl(entry);
|
|
500
|
-
});
|
|
501
|
-
ro.observe(el, {
|
|
502
|
-
box: 'content-box'
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
// initial sync (in case observer doesn't fire immediately)
|
|
506
|
-
var rect = el.getBoundingClientRect();
|
|
507
|
-
api.__render({
|
|
508
|
-
width: normalizeSize(rect.width, (_lastProps$width2 = lastProps.width) !== null && _lastProps$width2 !== void 0 ? _lastProps$width2 : 1),
|
|
509
|
-
height: normalizeSize(rect.height, (_lastProps$height2 = lastProps.height) !== null && _lastProps$height2 !== void 0 ? _lastProps$height2 : 1)
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
var lastProps = _objectSpread({}, props);
|
|
513
|
-
function normalizeSize(n) {
|
|
514
|
-
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
515
|
-
var v = typeof n === 'string' ? parseFloat(n) : n;
|
|
516
|
-
return Number.isFinite(v) && v > 0 ? v : fallback;
|
|
517
|
-
}
|
|
518
447
|
var api = {
|
|
519
448
|
// internal: rerender wrapper with latest props if host calls renderKitchenSimulator again
|
|
520
449
|
__render: function __render(nextProps) {
|
|
521
|
-
|
|
522
|
-
root.render(/*#__PURE__*/React.createElement(Wrapper, lastProps));
|
|
450
|
+
root.render(/*#__PURE__*/React.createElement(Wrapper, nextProps));
|
|
523
451
|
},
|
|
524
452
|
/**
|
|
525
453
|
* Send one or many events (in order).
|
|
@@ -603,17 +531,6 @@ export function renderKitchenSimulator(container) {
|
|
|
603
531
|
container[API_KEY] = null;
|
|
604
532
|
}
|
|
605
533
|
};
|
|
606
|
-
if (ro) {
|
|
607
|
-
try {
|
|
608
|
-
ro.disconnect();
|
|
609
|
-
} catch (_unused2) {}
|
|
610
|
-
ro = null;
|
|
611
|
-
}
|
|
612
|
-
roEl = null;
|
|
613
|
-
if (roRaf) {
|
|
614
|
-
cancelAnimationFrame(roRaf);
|
|
615
|
-
roRaf = 0;
|
|
616
|
-
}
|
|
617
534
|
|
|
618
535
|
// Prefer microtask when available, otherwise macrotask
|
|
619
536
|
if (typeof queueMicrotask === 'function') queueMicrotask(doUnmount);else setTimeout(doUnmount, 0);
|
|
@@ -623,20 +540,6 @@ export function renderKitchenSimulator(container) {
|
|
|
623
540
|
// first render
|
|
624
541
|
api.__render(props);
|
|
625
542
|
|
|
626
|
-
// Install observer after initial mount.
|
|
627
|
-
// If #content-box is created later, retry a few frames.
|
|
628
|
-
(function tryInstall() {
|
|
629
|
-
var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
630
|
-
if (destroyed) return;
|
|
631
|
-
installContentBoxObserver();
|
|
632
|
-
if (!ro && attempt < 30) {
|
|
633
|
-
// element not found yet; retry next frame for up to ~30 frames
|
|
634
|
-
requestAnimationFrame(function () {
|
|
635
|
-
return tryInstall(attempt + 1);
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
})();
|
|
639
|
-
|
|
640
543
|
// store api on container so repeated calls reuse it
|
|
641
544
|
container[API_KEY] = api;
|
|
642
545
|
return api;
|
package/es/utils/geometry.js
CHANGED
|
@@ -1873,7 +1873,7 @@ export function getAllHoleRect(scene, val) {
|
|
|
1873
1873
|
layer.lines.forEach(function (line) {
|
|
1874
1874
|
line.holes.forEach(function (holeID) {
|
|
1875
1875
|
var hole = layer.holes.get(holeID);
|
|
1876
|
-
holes.push(hole);
|
|
1876
|
+
if (hole) holes.push(hole);
|
|
1877
1877
|
});
|
|
1878
1878
|
});
|
|
1879
1879
|
var i = 0;
|
package/lib/class/item.js
CHANGED
|
@@ -36,9 +36,11 @@ var Item = exports["default"] = /*#__PURE__*/function () {
|
|
|
36
36
|
return (0, _createClass2["default"])(Item, null, [{
|
|
37
37
|
key: "create",
|
|
38
38
|
value: function create(state, layerID, type, x, y, width, height, rotation, isDuplication) {
|
|
39
|
+
var _item;
|
|
39
40
|
var molding = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : [];
|
|
40
41
|
var isInitialPos = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false;
|
|
41
42
|
var refItem = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : null;
|
|
43
|
+
var counterTopURI = arguments.length > 12 && arguments[12] !== undefined ? arguments[12] : null;
|
|
42
44
|
var itemID = _export2.IDBroker.acquireID();
|
|
43
45
|
var item = state.catalog.factoryElement(type, {
|
|
44
46
|
id: itemID,
|
|
@@ -167,6 +169,9 @@ var Item = exports["default"] = /*#__PURE__*/function () {
|
|
|
167
169
|
}
|
|
168
170
|
};
|
|
169
171
|
item.category === 'cabinet' && setSizeOfItemByDoorStyle();
|
|
172
|
+
if (counterTopURI || (_item = item) !== null && _item !== void 0 && _item.counterTop) {
|
|
173
|
+
item.counterTop.uri = counterTopURI;
|
|
174
|
+
}
|
|
170
175
|
item = this.updateDoorHandle(item, state.getIn(['scene', 'layers', layerID]));
|
|
171
176
|
state = state.setIn(['scene', 'layers', layerID, 'items', itemID], item);
|
|
172
177
|
if (item.type.includes('Light')) {
|
|
@@ -338,17 +343,17 @@ var Item = exports["default"] = /*#__PURE__*/function () {
|
|
|
338
343
|
if (isRect) {
|
|
339
344
|
var _this$create2 = this.create(state, layerID, sceneComponentType, x - width * Math.cos(rotRad), y - width * Math.sin(rotRad), 200, 100, rotRad * 180 / Math.PI, true, myObject.molding, false, myObject),
|
|
340
345
|
_stateI = _this$create2.updatedState,
|
|
341
|
-
|
|
342
|
-
duplicatedElement =
|
|
343
|
-
if (
|
|
346
|
+
_item2 = _this$create2.item;
|
|
347
|
+
duplicatedElement = _item2;
|
|
348
|
+
if (_item2 === null) {
|
|
344
349
|
alert('There are no Door Colors in this cabinet.');
|
|
345
350
|
state = state.merge({
|
|
346
351
|
mode: _constants.MODE_IDLE,
|
|
347
352
|
drawingSupport: new _immutable.Map()
|
|
348
353
|
});
|
|
349
354
|
} else {
|
|
350
|
-
state = Item.select(_stateI, layerID,
|
|
351
|
-
state = state.setIn(['drawingSupport', 'currentID'],
|
|
355
|
+
state = Item.select(_stateI, layerID, _item2.id).updatedState;
|
|
356
|
+
state = state.setIn(['drawingSupport', 'currentID'], _item2.id);
|
|
352
357
|
}
|
|
353
358
|
} else {
|
|
354
359
|
var _val2 = {
|
|
@@ -365,17 +370,17 @@ var Item = exports["default"] = /*#__PURE__*/function () {
|
|
|
365
370
|
if (isRectDown) {
|
|
366
371
|
var _this$create3 = this.create(state, layerID, sceneComponentType, x - depth * Math.sin(rotRad), y - depth * Math.cos(rotRad), 200, 100, rotRad * 180 / Math.PI, true, myObject.molding, false, myObject),
|
|
367
372
|
_stateI2 = _this$create3.updatedState,
|
|
368
|
-
|
|
369
|
-
duplicatedElement =
|
|
370
|
-
if (
|
|
373
|
+
_item3 = _this$create3.item;
|
|
374
|
+
duplicatedElement = _item3;
|
|
375
|
+
if (_item3 === null) {
|
|
371
376
|
alert('There are no Door Colors in this cabinet.');
|
|
372
377
|
state = state.merge({
|
|
373
378
|
mode: _constants.MODE_IDLE,
|
|
374
379
|
drawingSupport: new _immutable.Map()
|
|
375
380
|
});
|
|
376
381
|
} else {
|
|
377
|
-
state = Item.select(_stateI2, layerID,
|
|
378
|
-
state = state.setIn(['drawingSupport', 'currentID'],
|
|
382
|
+
state = Item.select(_stateI2, layerID, _item3.id).updatedState;
|
|
383
|
+
state = state.setIn(['drawingSupport', 'currentID'], _item3.id);
|
|
379
384
|
}
|
|
380
385
|
} else {
|
|
381
386
|
var _val3 = {
|
|
@@ -392,17 +397,17 @@ var Item = exports["default"] = /*#__PURE__*/function () {
|
|
|
392
397
|
if (isRectUp) {
|
|
393
398
|
var _this$create4 = this.create(state, layerID, sceneComponentType, x + depth * Math.sin(rotRad), y + depth * Math.cos(rotRad), 200, 100, rotRad * 180 / Math.PI, true, myObject.molding, false, myObject),
|
|
394
399
|
_stateI3 = _this$create4.updatedState,
|
|
395
|
-
|
|
396
|
-
duplicatedElement =
|
|
397
|
-
if (
|
|
400
|
+
_item4 = _this$create4.item;
|
|
401
|
+
duplicatedElement = _item4;
|
|
402
|
+
if (_item4 === null) {
|
|
398
403
|
alert('There are no Door Colors in this cabinet.');
|
|
399
404
|
state = state.merge({
|
|
400
405
|
mode: _constants.MODE_IDLE,
|
|
401
406
|
drawingSupport: new _immutable.Map()
|
|
402
407
|
});
|
|
403
408
|
} else {
|
|
404
|
-
state = Item.select(_stateI3, layerID,
|
|
405
|
-
state = state.setIn(['drawingSupport', 'currentID'],
|
|
409
|
+
state = Item.select(_stateI3, layerID, _item4.id).updatedState;
|
|
410
|
+
state = state.setIn(['drawingSupport', 'currentID'], _item4.id);
|
|
406
411
|
}
|
|
407
412
|
} else {
|
|
408
413
|
console.log('there is no space');
|
|
@@ -539,8 +544,14 @@ var Item = exports["default"] = /*#__PURE__*/function () {
|
|
|
539
544
|
}, {
|
|
540
545
|
key: "replaceItem",
|
|
541
546
|
value: function replaceItem(state, selectedPos, currentObject, selectedObject) {
|
|
547
|
+
var _currentObject$counte;
|
|
548
|
+
var counterTopURI = '';
|
|
549
|
+
if (!(0, _utils.isEmpty)(currentObject === null || currentObject === void 0 || (_currentObject$counte = currentObject.counterTop) === null || _currentObject$counte === void 0 ? void 0 : _currentObject$counte.uri)) {
|
|
550
|
+
var _currentObject$counte2;
|
|
551
|
+
counterTopURI = currentObject === null || currentObject === void 0 || (_currentObject$counte2 = currentObject.counterTop) === null || _currentObject$counte2 === void 0 ? void 0 : _currentObject$counte2.uri;
|
|
552
|
+
} else if (!(0, _utils.isEmpty)(state.getIn(['scene', 'layers', 'layer-1', 'counterTop']))) counterTopURI = state.getIn(['scene', 'layers', 'layer-1', 'counterTop']).uri;else counterTopURI = 'https://media.test.diydesignspace.com/uploads/CountTop/202105074107_5/texture/Unique_Calcatta_texture.jpg';
|
|
542
553
|
state = this.remove(state, state.scene.selectedLayer, selectedPos.selectedItemId).updatedState;
|
|
543
|
-
state = this.create(state, state.scene.selectedLayer, selectedObject.name, selectedPos.x, selectedPos.y, selectedObject.info.width, selectedObject.info.height, selectedPos.rotation, false).updatedState;
|
|
554
|
+
state = this.create(state, state.scene.selectedLayer, selectedObject.name, selectedPos.x, selectedPos.y, selectedObject.info.width, selectedObject.info.height, selectedPos.rotation, false, [], false, null, counterTopURI).updatedState;
|
|
544
555
|
// state = this.select(state, state.scene.selectedLayer, selectedPos.selectedItemId).updatedState;
|
|
545
556
|
return {
|
|
546
557
|
updatedState: state
|
package/lib/class/project.js
CHANGED
|
@@ -844,8 +844,8 @@ var Project = exports["default"] = /*#__PURE__*/function () {
|
|
|
844
844
|
});
|
|
845
845
|
var _viewer2D = state.viewer2D;
|
|
846
846
|
var viewer = _viewer2D.toJS();
|
|
847
|
-
width = (0, _convertUnitsLite.convert)(width).from('
|
|
848
|
-
height = (0, _convertUnitsLite.convert)(height).from('
|
|
847
|
+
width = (0, _convertUnitsLite.convert)(width).from(state.getIn(['scene', 'layers', 'layer-1', 'unit'])).to('cm');
|
|
848
|
+
height = (0, _convertUnitsLite.convert)(height).from(state.getIn(['scene', 'layers', 'layer-1', 'unit'])).to('cm');
|
|
849
849
|
var layerID = state.scene.selectedLayer;
|
|
850
850
|
state = _export2.Item.setInitialDoorStyle(state, doorStyle).updatedState;
|
|
851
851
|
if ((0, _helper.isEmpty)(viewer)) return {
|
package/lib/index.js
CHANGED
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
exports.renderKitchenSimulator = renderKitchenSimulator;
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -18,8 +17,6 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
18
17
|
var _react = _interopRequireDefault(require("react"));
|
|
19
18
|
var _LiteRenderer = _interopRequireDefault(require("./LiteRenderer"));
|
|
20
19
|
var _client = require("react-dom/client");
|
|
21
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
20
|
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)); }
|
|
24
21
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
25
22
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
@@ -257,10 +254,10 @@ function renderKitchenSimulator(container) {
|
|
|
257
254
|
|
|
258
255
|
// ✅ Reuse existing API for same container
|
|
259
256
|
if (container[API_KEY]) {
|
|
260
|
-
var
|
|
261
|
-
|
|
262
|
-
(
|
|
263
|
-
return
|
|
257
|
+
var _container$API_KEY$__, _container$API_KEY;
|
|
258
|
+
// update render with latest props (safe)
|
|
259
|
+
(_container$API_KEY$__ = (_container$API_KEY = container[API_KEY]).__render) === null || _container$API_KEY$__ === void 0 || _container$API_KEY$__.call(_container$API_KEY, props);
|
|
260
|
+
return container[API_KEY];
|
|
264
261
|
}
|
|
265
262
|
|
|
266
263
|
// ✅ Reuse root for same container
|
|
@@ -455,79 +452,10 @@ function renderKitchenSimulator(container) {
|
|
|
455
452
|
}
|
|
456
453
|
}]);
|
|
457
454
|
}(_react["default"].Component);
|
|
458
|
-
var ro = null;
|
|
459
|
-
var roEl = null;
|
|
460
|
-
var roRaf = 0;
|
|
461
|
-
function installContentBoxObserver() {
|
|
462
|
-
var _lastProps$width2, _lastProps$height2;
|
|
463
|
-
if (typeof window === 'undefined') return;
|
|
464
|
-
if (typeof ResizeObserver === 'undefined') return;
|
|
465
|
-
var el = document.getElementById('content-box');
|
|
466
|
-
if (!el) return; // tool won't crash if element isn't there yet
|
|
467
|
-
|
|
468
|
-
roEl = el;
|
|
469
|
-
var syncFromEl = function syncFromEl(entry) {
|
|
470
|
-
var _lastProps$width, _lastProps$height;
|
|
471
|
-
// Prefer contentBoxSize when available; fallback to getBoundingClientRect.
|
|
472
|
-
var w = 0,
|
|
473
|
-
h = 0;
|
|
474
|
-
var cbs = entry === null || entry === void 0 ? void 0 : entry.contentBoxSize;
|
|
475
|
-
if (cbs) {
|
|
476
|
-
var _box$inlineSize, _box$blockSize;
|
|
477
|
-
// contentBoxSize can be array (Chrome) or single object (Firefox)
|
|
478
|
-
var box = Array.isArray(cbs) ? cbs[0] : cbs;
|
|
479
|
-
w = (_box$inlineSize = box === null || box === void 0 ? void 0 : box.inlineSize) !== null && _box$inlineSize !== void 0 ? _box$inlineSize : 0;
|
|
480
|
-
h = (_box$blockSize = box === null || box === void 0 ? void 0 : box.blockSize) !== null && _box$blockSize !== void 0 ? _box$blockSize : 0;
|
|
481
|
-
}
|
|
482
|
-
if (!w || !h) {
|
|
483
|
-
var _rect = roEl.getBoundingClientRect();
|
|
484
|
-
w = _rect.width;
|
|
485
|
-
h = _rect.height;
|
|
486
|
-
}
|
|
487
|
-
w = normalizeSize(w, (_lastProps$width = lastProps.width) !== null && _lastProps$width !== void 0 ? _lastProps$width : 1);
|
|
488
|
-
h = normalizeSize(h, (_lastProps$height = lastProps.height) !== null && _lastProps$height !== void 0 ? _lastProps$height : 1);
|
|
489
|
-
|
|
490
|
-
// avoid thrash: coalesce multiple observer callbacks into 1 RAF
|
|
491
|
-
if (roRaf) cancelAnimationFrame(roRaf);
|
|
492
|
-
roRaf = requestAnimationFrame(function () {
|
|
493
|
-
roRaf = 0;
|
|
494
|
-
if (destroyed) return;
|
|
495
|
-
// only update if changed (prevents infinite loops)
|
|
496
|
-
if (lastProps.width === w && lastProps.height === h) return;
|
|
497
|
-
// update props via existing render path
|
|
498
|
-
api.__render({
|
|
499
|
-
width: w,
|
|
500
|
-
height: h
|
|
501
|
-
});
|
|
502
|
-
});
|
|
503
|
-
};
|
|
504
|
-
ro = new ResizeObserver(function (entries) {
|
|
505
|
-
var entry = entries && entries[0];
|
|
506
|
-
if (!entry) return;
|
|
507
|
-
syncFromEl(entry);
|
|
508
|
-
});
|
|
509
|
-
ro.observe(el, {
|
|
510
|
-
box: 'content-box'
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
// initial sync (in case observer doesn't fire immediately)
|
|
514
|
-
var rect = el.getBoundingClientRect();
|
|
515
|
-
api.__render({
|
|
516
|
-
width: normalizeSize(rect.width, (_lastProps$width2 = lastProps.width) !== null && _lastProps$width2 !== void 0 ? _lastProps$width2 : 1),
|
|
517
|
-
height: normalizeSize(rect.height, (_lastProps$height2 = lastProps.height) !== null && _lastProps$height2 !== void 0 ? _lastProps$height2 : 1)
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
var lastProps = _objectSpread({}, props);
|
|
521
|
-
function normalizeSize(n) {
|
|
522
|
-
var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
523
|
-
var v = typeof n === 'string' ? parseFloat(n) : n;
|
|
524
|
-
return Number.isFinite(v) && v > 0 ? v : fallback;
|
|
525
|
-
}
|
|
526
455
|
var api = {
|
|
527
456
|
// internal: rerender wrapper with latest props if host calls renderKitchenSimulator again
|
|
528
457
|
__render: function __render(nextProps) {
|
|
529
|
-
|
|
530
|
-
root.render(/*#__PURE__*/_react["default"].createElement(Wrapper, lastProps));
|
|
458
|
+
root.render(/*#__PURE__*/_react["default"].createElement(Wrapper, nextProps));
|
|
531
459
|
},
|
|
532
460
|
/**
|
|
533
461
|
* Send one or many events (in order).
|
|
@@ -611,17 +539,6 @@ function renderKitchenSimulator(container) {
|
|
|
611
539
|
container[API_KEY] = null;
|
|
612
540
|
}
|
|
613
541
|
};
|
|
614
|
-
if (ro) {
|
|
615
|
-
try {
|
|
616
|
-
ro.disconnect();
|
|
617
|
-
} catch (_unused2) {}
|
|
618
|
-
ro = null;
|
|
619
|
-
}
|
|
620
|
-
roEl = null;
|
|
621
|
-
if (roRaf) {
|
|
622
|
-
cancelAnimationFrame(roRaf);
|
|
623
|
-
roRaf = 0;
|
|
624
|
-
}
|
|
625
542
|
|
|
626
543
|
// Prefer microtask when available, otherwise macrotask
|
|
627
544
|
if (typeof queueMicrotask === 'function') queueMicrotask(doUnmount);else setTimeout(doUnmount, 0);
|
|
@@ -631,20 +548,6 @@ function renderKitchenSimulator(container) {
|
|
|
631
548
|
// first render
|
|
632
549
|
api.__render(props);
|
|
633
550
|
|
|
634
|
-
// Install observer after initial mount.
|
|
635
|
-
// If #content-box is created later, retry a few frames.
|
|
636
|
-
(function tryInstall() {
|
|
637
|
-
var attempt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
638
|
-
if (destroyed) return;
|
|
639
|
-
installContentBoxObserver();
|
|
640
|
-
if (!ro && attempt < 30) {
|
|
641
|
-
// element not found yet; retry next frame for up to ~30 frames
|
|
642
|
-
requestAnimationFrame(function () {
|
|
643
|
-
return tryInstall(attempt + 1);
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
})();
|
|
647
|
-
|
|
648
551
|
// store api on container so repeated calls reuse it
|
|
649
552
|
container[API_KEY] = api;
|
|
650
553
|
return api;
|
package/lib/utils/geometry.js
CHANGED
|
@@ -1973,7 +1973,7 @@ function getAllHoleRect(scene, val) {
|
|
|
1973
1973
|
layer.lines.forEach(function (line) {
|
|
1974
1974
|
line.holes.forEach(function (holeID) {
|
|
1975
1975
|
var hole = layer.holes.get(holeID);
|
|
1976
|
-
holes.push(hole);
|
|
1976
|
+
if (hole) holes.push(hole);
|
|
1977
1977
|
});
|
|
1978
1978
|
});
|
|
1979
1979
|
var i = 0;
|